This crate should be used together with the buffin crate.
This crate enables you to automatically derive ToBytes and FromBytes for custom structs and enums, provided all fields within them implement ToBytes and FromBytes, respectively.
use Buffin;
use ;
// snip //
let my_enum = Variant1 ;
// Grab a bit of memory and stuff it in a Buffin instance.
// This can also be a vec. Keep in mind that the vec will never be resized.
let mut buffer = ;
let mut buffer = new;
// Put my_enum in the buffin.
buffer.add.expect;
// Check how many bytes we've used.
println!;
// Take it back out again.
let my_parsed_enum = buffer..expect;
It's possible to serialize multiple things into the same buffer.
// snip //
let mut buffer = ;
let mut buffer = new;
// Put some messages in the buffin.
buffer.add.expect;
buffer.add.expect;
buffer.add.expect;
// Check how many bytes we've used. It should be 37.
println!;
// Read them all back out again.
while let Ok = buffer.