This commit is contained in:
griffi-gh 2023-03-09 04:21:59 +01:00
parent 80c3f354f1
commit 7bcfc75dfe
2 changed files with 2 additions and 3 deletions

View file

@ -42,8 +42,7 @@ pub fn send_chunk_compressed(
message: &ServerToClientMessage
) -> Result<()> {
let mut ser_message = postcard::to_allocvec(&message)?;
let (_, data) = ser_message.split_at_mut(1);
let mut compressed = lz4_compress(&data);
let mut compressed = lz4_compress(&ser_message[1..]);
ser_message.truncate(1);
ser_message.append(&mut compressed);
let ser_message = ser_message.into_boxed_slice();

View file

@ -113,7 +113,7 @@ fn check_server_hello_response(
//TODO multithreaded decompression
fn decompress_chunk_packet(data: &Box<[u8]>) -> Result<ServerToClientMessage> {
let data_ref = &data[1..];
let decompressed = decompress_size_prepended(data_ref).ok().context("Decompress failed")?;
let decompressed = decompress_size_prepended(data_ref).map_err(|x| println!("{x}")).ok().context("Decompress failed")?;
let deserialized = postcard::from_bytes(&decompressed).ok().context("Deserialization failed")?;
Ok(deserialized)
}