Serialization of structure / enumeration in bytes

I would like to serialize my structure to binary and de-serialize it at the other end of the pipe. Is there any way to achieve this using box serialization? It seems to only support JSON, hex and base64.

+3
serialization rust
source share
1 answer

I would suggest bincode .

It provides encode() and decode() functions that work with anything with RustcEncodable and RustcDecodable traits, which can usually be #[derive] d, and return a Vec<u8> .

It has a few quirks ( isize and usize become i64 and u64 , for example), but basically they improve portability, and it works the way you expected.

0
source share

All Articles