bincode 0.9.0

A binary serialization / deserialization strategy that uses Serde for transforming structs into bytes and vice versa!
Documentation

bincode is a crate for encoding and decoding using a tiny binary serialization strategy.

There are simple functions for encoding to Vec<u8> and decoding from &[u8], but the meat of the library is the serialize_into and deserialize_from functions which respectively allow encoding into any std::io::Write or decode from any std::io::Read.

Modules

Until "default type parameters" lands, we have an extra module called endian_choice that duplicates all of the core bincode functionality but with the option to choose which endianness the integers are encoded using.

The default endianness is little.

Using Basic Functions

extern crate bincode;
use bincode::{serialize, deserialize, Bounded};
fn main() {
    // The object that we will serialize.
    let target = Some("hello world".to_string());
    // The maximum size of the encoded message.
    let limit = Bounded(20);

    let encoded: Vec<u8>        = serialize(&target, limit).unwrap();
    let decoded: Option<String> = deserialize(&encoded[..]).unwrap();
    assert_eq!(target, decoded);
}