Crate bincode2

Source
Expand description

Bincode2 is a crate for encoding and decoding using a tiny binary serialization strategy. Using it, you can easily go from having an object in memory, quickly serialize it to bytes, and then deserialize it back just as fast!

§Using Basic Functions

fn main() {
    // The object that we will serialize.
    let target: Option<String>  = Some("hello world".to_string());

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

Structs§

Config
A configuration builder whose options Bincode will use while serializing and deserializing.

Enums§

ErrorKind
The kind of error that can be produced during a serialization or deserialization.
LengthOption
Used to specify the unit used for length of strings and arrays via config.string_length or config.array_length.

Traits§

BincodeRead
An optional Read trait for advanced Bincode usage.

Functions§

config
Get a default configuration object.
deserialize
Deserializes a slice of bytes into an instance of T using the default configuration.
deserialize_from
Deserializes an object directly from a Reader using the default configuration.
deserialize_from_custom
Deserializes an object from a custom BincodeReader using the default configuration. It is highly recommended to use deserialize_from unless you need to implement BincodeRead for performance reasons.
serialize
Serializes a serializable object into a Vec of bytes using the default configuration.
serialize_into
Serializes an object directly into a Writer using the default configuration.
serialized_size
Returns the size that an object would be if serialized using Bincode with the default configuration.

Type Aliases§

Error
An error that can be produced during (de)serializing.
Result
The result of a serialization or deserialization operation.