diff --git a/src/client/mudlet.rs b/src/client/mudlet.rs index e71bc77..1858927 100644 --- a/src/client/mudlet.rs +++ b/src/client/mudlet.rs @@ -5,6 +5,7 @@ use serde_json::{Map, Value}; type Result = std::result::Result>; +/// try to parse a 32bit int from the delta chunk, then another 32bit in from the size chunk fn chunk32(chunk: &Vec) -> Result<(i32, i32)> { let (delta_chunk, size_chunk) = { let (mut delta_chunk, mut size_chunk): ([u8; 4], [u8; 4]) = ([0; 4], [0; 4]); @@ -25,6 +26,7 @@ fn chunk32(chunk: &Vec) -> Result<(i32, i32)> { Ok((delta, size)) } +/// try to parse a 64bit int from the delta chunk, then a 32bit int from the size chunk fn chunk64(delta_chunk: &Vec, size_chunk: &Vec) -> Result<(i32, i32)> { let delta = i64::from_be_bytes(delta_chunk.as_slice().try_into()?); let size = i32::from_be_bytes(size_chunk.as_slice().try_into()?); @@ -42,6 +44,7 @@ fn chunk64(delta_chunk: &Vec, size_chunk: &Vec) -> Result<(i32, i32)> { Ok((delta, size)) } +/// parse the log of raw bytes and make some nice json for clients pub fn parse_log(raw: &Vec) -> Result { let mut raw = raw.to_owned(); let mut chunks: Vec> = Vec::new();