Lightpack
A lighweight, no-std binary serialization library.
Example
Lightpack provides derivable traits for encoding (Pack
) and decoding (Unpack
), as well as for determining a type's encoded size (Size
):
To encode, call pack
with an endianness (e.g. lightpack::byteorder::BigEndian
) on a &mut [u8]
slice:
let mut buffer = ;
Point .;
// => buffer == [0, 3, 0, 4]
To decode, call unpack
on a &[u8]
slice:
.unwrap
// => Point { x: 3, y: 4 }
For a complete example, check out examples/point.rs
.