Module bincode::config[][src]

Expand description

bincode uses a Builder-pattern to configure the Serializers and Deserializers in this crate. This means that if you need to customize the behavior of bincode, you should create an instance of the DefaultOptions struct:

use bincode::Options;
let my_options = bincode::DefaultOptions::new();

Options Struct vs bincode functions

Due to historical reasons, the default options used by the serialize() and deserialize() family of functions are different than the default options created by the DefaultOptions struct:

Byte limitEndiannessInt EncodingTrailing Behavior
structUnlimitedLittleVarintReject
functionUnlimitedLittleFixintAllow

This means that if you want to use the Serialize / Deserialize structs with the same settings as the functions, you should adjust the DefaultOptions struct like so:

use bincode::Options;
let my_options = bincode::DefaultOptions::new()
    .with_fixint_encoding()
    .allow_trailing_bytes();

Structs

AllowTrailing

A TrailingBytes config that will allow trailing bytes in slices after deserialization.

BigEndian

Big-endian byte ordering.

Bounded

A SizeLimit that restricts serialized or deserialized messages from exceeding a certain byte length.

ConfigDeprecated

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

DefaultOptions

The default options for bincode serialization/deserialization.

FixintEncoding

Fixed-size integer encoding.

Infinite

A SizeLimit without a limit! Use this if you don’t care about the size of encoded or decoded messages.

LittleEndian

Little-endian byte ordering.

NativeEndian

The native byte ordering of the current system.

RejectTrailing

A TrailingBytes config that will cause bincode to produce an error if bytes are left over in the slice when deserialization is complete.

VarintEncoding

Variable-size integer encoding (excepting [ui]8).

WithOtherEndian

A configuration struct with a user-specified endian order

WithOtherIntEncoding

A configuration struct with a user-specified length encoding

WithOtherLimit

A configuration struct with a user-specified byte limit

WithOtherTrailing

A configuration struct with a user-specified trailing bytes behavior.

Traits

Options

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