From b8ad94cd5061445a45d0790eee36014d34ad6817 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Sat, 22 Feb 2025 22:59:01 +0100 Subject: replace deprecated failure crate with thiserror this changes the public API in that all our methods now return a proper ProtocolError crate. Needed change anyways to properly deal with all our errors in the long run. Will still need to do a pass through the crate to remove all existing unwraps where it makes sense. --- src/message/handshake/types.rs | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'src/message/handshake/types.rs') diff --git a/src/message/handshake/types.rs b/src/message/handshake/types.rs index 6d4960d..fd8c8fa 100644 --- a/src/message/handshake/types.rs +++ b/src/message/handshake/types.rs @@ -1,8 +1,6 @@ use std::result::Result; use std::vec::Vec; -use failure::Error; - use crate::error::ProtocolError; use crate::primitive::Variant; use crate::util; @@ -12,7 +10,7 @@ use crate::message::handshake::{HandshakeDeserialize, HandshakeSerialize}; use crate::primitive::VariantMap; impl HandshakeSerialize for VariantMap { - fn serialize<'a>(&'a self) -> Result, Error> { + fn serialize<'a>(&'a self) -> Result, ProtocolError> { let mut res: Vec = Vec::new(); for (k, v) in self { @@ -29,7 +27,7 @@ impl HandshakeSerialize for VariantMap { } impl HandshakeDeserialize for VariantMap { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> { + fn parse(b: &[u8]) -> Result<(usize, Self), ProtocolError> { let (_, len) = i32::parse(&b[0..4])?; let mut pos: usize = 4; @@ -45,7 +43,7 @@ impl HandshakeDeserialize for VariantMap { match name { Variant::String(x) => map.insert(x, value), Variant::ByteArray(x) => map.insert(x, value), - _ => bail!(ProtocolError::WrongVariant), + _ => return Err(ProtocolError::WrongVariant), }; } @@ -58,21 +56,18 @@ pub fn serialize_variantmap() { let mut test_variantmap = VariantMap::new(); test_variantmap.insert("Configured".to_string(), Variant::bool(true)); let bytes = [ - 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 0, 20, 0, 67, 0, 111, 0, 110, 0, 102, 0, 105, 0, 103, 0, - 117, 0, 114, 0, 101, 0, 100, 0, 0, 0, 1, 0, 1, + 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 0, 20, 0, 67, 0, 111, 0, 110, 0, 102, 0, 105, 0, 103, 0, 117, 0, + 114, 0, 101, 0, 100, 0, 0, 0, 1, 0, 1, ] .to_vec(); - assert_eq!( - HandshakeSerialize::serialize(&test_variantmap).unwrap(), - bytes - ); + assert_eq!(HandshakeSerialize::serialize(&test_variantmap).unwrap(), bytes); } #[test] pub fn deserialize_variantmap() { let test_bytes: &[u8] = &[ - 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 0, 20, 0, 67, 0, 111, 0, 110, 0, 102, 0, 105, 0, 103, 0, - 117, 0, 114, 0, 101, 0, 100, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, + 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 0, 20, 0, 67, 0, 111, 0, 110, 0, 102, 0, 105, 0, 103, 0, 117, 0, + 114, 0, 101, 0, 100, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, ]; let mut test_variantmap = VariantMap::new(); test_variantmap.insert("Configured".to_string(), Variant::bool(true)); @@ -86,8 +81,8 @@ pub fn deserialize_variantmap() { #[test] pub fn deserialize_variantmap_utf8() { let test_bytes: &[u8] = &[ - 0, 0, 0, 2, 0, 0, 0, 12, 0, 0, 0, 0, 10, 67, 111, 110, 102, 105, 103, 117, 114, 101, 100, - 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, + 0, 0, 0, 2, 0, 0, 0, 12, 0, 0, 0, 0, 10, 67, 111, 110, 102, 105, 103, 117, 114, 101, 100, 0, 0, 0, 1, + 0, 1, 0, 0, 0, 1, ]; let mut test_variantmap = VariantMap::new(); test_variantmap.insert("Configured".to_string(), Variant::bool(true)); -- cgit v1.2.3 com?h=1-url-preview&id=bf06821e77078c10ab3cdd7ea3a364030c144e16&showmsg=1&follow=1'>github.com/jsonnet-libs/k8s-alpha/1.19/_gen/networking/v1/ingress.libsonnet (unfollow)
Commit message (Collapse)AuthorLines
2021-05-26fix log breaking once buffer fullMax Audron-2/+33
the log_msg function was poping the newest message and replacing it with the newest message, it should be poping the oldest messages.
2021-05-16add deployment stuffMax Audron-6/+27786
2021-05-15add container buildMax Audron-2/+35