From 0f26b1bad20ce68efa0c9296143f3176e93977b6 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Mon, 4 Jan 2021 18:24:38 +0100 Subject: random stuff --- src/message/handshake/init.rs | 1 + src/primitive/string.rs | 7 +++++-- src/primitive/variantlist.rs | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/message/handshake/init.rs b/src/message/handshake/init.rs index 860df8a..b4604b6 100644 --- a/src/message/handshake/init.rs +++ b/src/message/handshake/init.rs @@ -2,6 +2,7 @@ use crate::Deserialize; use crate::Serialize; /// The first few bytes sent to the core to initialize the connection and setup if we want to use tls and compression +#[derive(Clone, Debug)] pub struct Init { pub tls: bool, pub compression: bool, diff --git a/src/primitive/string.rs b/src/primitive/string.rs index 86bcdec..dcd4f7c 100644 --- a/src/primitive/string.rs +++ b/src/primitive/string.rs @@ -7,8 +7,8 @@ use failure::Error; use log::trace; -use crate::{Deserialize, DeserializeUTF8, Serialize, SerializeUTF8}; use crate::util; +use crate::{Deserialize, DeserializeUTF8, Serialize, SerializeUTF8}; /// We Shadow the String type here as we can only use impl on types in our own scope. /// @@ -33,7 +33,6 @@ impl SerializeUTF8 for String { fn serialize_utf8(&self) -> Result, Error> { let mut res: Vec = Vec::new(); res.extend(self.clone().into_bytes()); - res.extend(vec![0x00]); util::prepend_byte_len(&mut res); return Ok(res); } @@ -64,6 +63,7 @@ impl Deserialize for String { } let res: String = String::from_utf16(&chars).unwrap(); + trace!("parsed string: {}", res); return Ok((pos, res)); } } @@ -81,6 +81,7 @@ impl DeserializeUTF8 for String { let ulen = len as usize; let mut res: String = String::from_utf8(b[4..(ulen + 4)].to_vec())?; + trace!("parsed string: {}", res); // If the last byte is zero remove it // Receiving a string as bytearray will sometimes have @@ -89,6 +90,8 @@ impl DeserializeUTF8 for String { let _ = res.pop(); } + trace!("parsed string after trunc: {}", res); + return Ok((ulen + 4, res)); } } diff --git a/src/primitive/variantlist.rs b/src/primitive/variantlist.rs index 452b927..a802864 100644 --- a/src/primitive/variantlist.rs +++ b/src/primitive/variantlist.rs @@ -40,6 +40,7 @@ impl Deserialize for VariantList { for i in 0..len { trace!(target: "primitive::VariantList", "Parsing VariantList element: {:?}", i); let (vlen, val) = Variant::parse(&b[pos..])?; + trace!("parsed variant: {:?}", val); res.push(val); pos += vlen; } -- cgit v1.2.3