Trait bincode::config::Options [−][src]
pub trait Options: InternalOptions + Sized {}Show methods
fn with_no_limit(self) -> WithOtherLimit<Self, Infinite> { ... } fn with_limit(self, limit: u64) -> WithOtherLimit<Self, Bounded> { ... } fn with_little_endian(self) -> WithOtherEndian<Self, LittleEndian> { ... } fn with_big_endian(self) -> WithOtherEndian<Self, BigEndian> { ... } fn with_native_endian(self) -> WithOtherEndian<Self, NativeEndian> { ... } fn with_varint_encoding(self) -> WithOtherIntEncoding<Self, VarintEncoding> { ... } fn with_fixint_encoding(self) -> WithOtherIntEncoding<Self, FixintEncoding> { ... } fn reject_trailing_bytes(self) -> WithOtherTrailing<Self, RejectTrailing> { ... } fn allow_trailing_bytes(self) -> WithOtherTrailing<Self, AllowTrailing> { ... } fn serialize<S: ?Sized + Serialize>(self, t: &S) -> Result<Vec<u8>> { ... } fn serialized_size<T: ?Sized + Serialize>(self, t: &T) -> Result<u64> { ... } fn serialize_into<W: Write, T: ?Sized + Serialize>(
self,
w: W,
t: &T
) -> Result<()> { ... } fn deserialize<'a, T: Deserialize<'a>>(self, bytes: &'a [u8]) -> Result<T> { ... } fn deserialize_seed<'a, T: DeserializeSeed<'a>>(
self,
seed: T,
bytes: &'a [u8]
) -> Result<T::Value> { ... } fn deserialize_from<R: Read, T: DeserializeOwned>(
self,
reader: R
) -> Result<T> { ... } fn deserialize_from_seed<'a, R: Read, T: DeserializeSeed<'a>>(
self,
seed: T,
reader: R
) -> Result<T::Value> { ... } fn deserialize_from_custom<'a, R: BincodeRead<'a>, T: DeserializeOwned>(
self,
reader: R
) -> Result<T> { ... } fn deserialize_from_custom_seed<'a, R: BincodeRead<'a>, T: DeserializeSeed<'a>>(
self,
seed: T,
reader: R
) -> Result<T::Value> { ... }
Expand description
A configuration builder trait whose options Bincode will use while serializing and deserializing.
Options
Endianness: The endianness with which multi-byte integers will be read/written. default: little endian
Limit: The maximum number of bytes that will be read/written in a bincode serialize/deserialize. default: unlimited
Int Encoding: The encoding used for numbers, enum discriminants, and lengths. default: varint
Trailing Behavior: The behavior when there are trailing bytes left over in a slice after deserialization. default: reject
Byte Limit Details
The purpose of byte-limiting is to prevent Denial-Of-Service attacks whereby malicious attackers get bincode deserialization to crash your process by allocating too much memory or keeping a connection open for too long.
When a byte limit is set, bincode will return Err
on any deserialization that goes over the limit, or any
serialization that goes over the limit.
Provided methods
fn with_no_limit(self) -> WithOtherLimit<Self, Infinite>
[src]
fn with_no_limit(self) -> WithOtherLimit<Self, Infinite>
[src]Sets the byte limit to be unlimited. This is the default.
fn with_limit(self, limit: u64) -> WithOtherLimit<Self, Bounded>
[src]
fn with_limit(self, limit: u64) -> WithOtherLimit<Self, Bounded>
[src]Sets the byte limit to limit
.
fn with_little_endian(self) -> WithOtherEndian<Self, LittleEndian>
[src]
fn with_little_endian(self) -> WithOtherEndian<Self, LittleEndian>
[src]Sets the endianness to little-endian This is the default.
fn with_big_endian(self) -> WithOtherEndian<Self, BigEndian>
[src]
fn with_big_endian(self) -> WithOtherEndian<Self, BigEndian>
[src]Sets the endianness to big-endian
fn with_native_endian(self) -> WithOtherEndian<Self, NativeEndian>
[src]
fn with_native_endian(self) -> WithOtherEndian<Self, NativeEndian>
[src]Sets the endianness to the the machine-native endianness
fn with_varint_encoding(self) -> WithOtherIntEncoding<Self, VarintEncoding>
[src]
fn with_varint_encoding(self) -> WithOtherIntEncoding<Self, VarintEncoding>
[src]Sets the length encoding to varint
fn with_fixint_encoding(self) -> WithOtherIntEncoding<Self, FixintEncoding>
[src]
fn with_fixint_encoding(self) -> WithOtherIntEncoding<Self, FixintEncoding>
[src]Sets the length encoding to be fixed
fn reject_trailing_bytes(self) -> WithOtherTrailing<Self, RejectTrailing>
[src]
fn reject_trailing_bytes(self) -> WithOtherTrailing<Self, RejectTrailing>
[src]Sets the deserializer to reject trailing bytes
fn allow_trailing_bytes(self) -> WithOtherTrailing<Self, AllowTrailing>
[src]
fn allow_trailing_bytes(self) -> WithOtherTrailing<Self, AllowTrailing>
[src]Sets the deserializer to allow trailing bytes
Serializes a serializable object into a Vec
of bytes using this configuration
Returns the size that an object would be if serialized using Bincode with this configuration
Serializes an object directly into a Writer
using this configuration
If the serialization would take more bytes than allowed by the size limit, an error
is returned and no bytes will be written into the Writer
fn deserialize<'a, T: Deserialize<'a>>(self, bytes: &'a [u8]) -> Result<T>
[src]
fn deserialize<'a, T: Deserialize<'a>>(self, bytes: &'a [u8]) -> Result<T>
[src]Deserializes a slice of bytes into an instance of T
using this configuration
fn deserialize_seed<'a, T: DeserializeSeed<'a>>(
self,
seed: T,
bytes: &'a [u8]
) -> Result<T::Value>
[src]
fn deserialize_seed<'a, T: DeserializeSeed<'a>>(
self,
seed: T,
bytes: &'a [u8]
) -> Result<T::Value>
[src]Deserializes a slice of bytes with state seed
using this configuration.
fn deserialize_from<R: Read, T: DeserializeOwned>(self, reader: R) -> Result<T>
[src]
fn deserialize_from<R: Read, T: DeserializeOwned>(self, reader: R) -> Result<T>
[src]Deserializes an object directly from a Read
er using this configuration
If this returns an Error
, reader
may be in an invalid state.
fn deserialize_from_seed<'a, R: Read, T: DeserializeSeed<'a>>(
self,
seed: T,
reader: R
) -> Result<T::Value>
[src]
fn deserialize_from_seed<'a, R: Read, T: DeserializeSeed<'a>>(
self,
seed: T,
reader: R
) -> Result<T::Value>
[src]Deserializes an object directly from a Read
er with state seed
using this configuration
If this returns an Error
, reader
may be in an invalid state.
fn deserialize_from_custom<'a, R: BincodeRead<'a>, T: DeserializeOwned>(
self,
reader: R
) -> Result<T>
[src]
fn deserialize_from_custom<'a, R: BincodeRead<'a>, T: DeserializeOwned>(
self,
reader: R
) -> Result<T>
[src]Deserializes an object from a custom BincodeRead
er using the default configuration.
It is highly recommended to use deserialize_from
unless you need to implement
BincodeRead
for performance reasons.
If this returns an Error
, reader
may be in an invalid state.
fn deserialize_from_custom_seed<'a, R: BincodeRead<'a>, T: DeserializeSeed<'a>>(
self,
seed: T,
reader: R
) -> Result<T::Value>
[src]
fn deserialize_from_custom_seed<'a, R: BincodeRead<'a>, T: DeserializeSeed<'a>>(
self,
seed: T,
reader: R
) -> Result<T::Value>
[src]Deserializes an object from a custom BincodeRead
er with state seed
using the default
configuration. It is highly recommended to use deserialize_from
unless you need to
implement BincodeRead
for performance reasons.
If this returns an Error
, reader
may be in an invalid state.