Open
Description
i couldn't find anything related in the issue tracker, so here i am 😇
let's say i have the following piece of code
fn ser(obj: impl CanonicalSerialize, compress: Compress) -> Vec<u8> {
let mut serialized = vec![0; obj.serialized_size(compress)];
obj.serialize_with_mode(&mut serialized[..], compress)?;
serialized
}
is it possible, on the other end of the protocol, to deserialize the bytes without passing around the same compress: Compress
, e.g. maybe the information about compression is inside the bytes or something?
i.e. i'm wondering if something like the following is possible
fn deser(bytes: &[u8], validate: Validate) -> Result<MyStruct> {
let compress = is_it_compressed_or_not(bytes); // this is the part i couldn't find
let my_struct = Block::deserialize_with_mode(&bytes[..], compress, validate)?
Ok(my_struct)
}
thanks and cheers 🥳 👋
Metadata
Metadata
Assignees
Labels
No labels