Expand description
Bincode 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> = bincode::serialize(&target).unwrap();
let decoded: Option<String> = bincode::deserialize(&encoded[..]).unwrap();
assert_eq!(target, decoded);
}§128bit numbers
Support for i128 and u128 is automatically enabled on Rust toolchains
greater than or equal to 1.26.0 and disabled for targets which do not support it
Re-exports§
pub use config::Config;Deprecated pub use config::DefaultOptions;pub use config::Options;pub use de::read::BincodeRead;pub use de::Deserializer;
Modules§
bincodeuses a Builder-pattern to configure the Serializers and Deserializers in this crate. This means that if you need to customize the behavior ofbincode, you should create an instance of theDefaultOptionsstruct:- Deserialize bincode data to a Rust data structure.
Structs§
- An Serializer that encodes values directly into a Writer.
Enums§
- The kind of error that can be produced during a serialization or deserialization.
Functions§
- config
Deprecated Get a default configuration object. - Deserializes a slice of bytes into an instance of
Tusing the default configuration. - Deserializes an object directly from a
Reader using the default configuration. - Deserializes an object from a custom
BincodeReader using the default configuration. It is highly recommended to usedeserialize_fromunless you need to implementBincodeReadfor performance reasons. - Get a default configuration object.
- Serializes a serializable object into a
Vecof bytes using the default configuration. - Serializes an object directly into a
Writerusing the default configuration. - Returns the size that an object would be if serialized using Bincode with the default configuration.
Type Aliases§
- An error that can be produced during (de)serializing.
- The result of a serialization or deserialization operation.