[−][src]Struct bincode::Config
A configuration builder 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
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.
Methods
impl Config[src]
impl Configpub fn no_limit(&mut self) -> &mut Self[src]
pub fn no_limit(&mut self) -> &mut SelfSets the byte limit to be unlimited. This is the default.
pub fn limit(&mut self, limit: u64) -> &mut Self[src]
pub fn limit(&mut self, limit: u64) -> &mut SelfSets the byte limit to limit.
pub fn little_endian(&mut self) -> &mut Self[src]
pub fn little_endian(&mut self) -> &mut SelfSets the endianness to little-endian This is the default.
pub fn big_endian(&mut self) -> &mut Self[src]
pub fn big_endian(&mut self) -> &mut SelfSets the endianness to big-endian
pub fn native_endian(&mut self) -> &mut Self[src]
pub fn native_endian(&mut self) -> &mut SelfSets the endianness to the the machine-native endianness
pub fn serialize<T: ?Sized + Serialize>(&self, t: &T) -> Result<Vec<u8>>[src]
pub fn serialize<T: ?Sized + Serialize>(&self, t: &T) -> Result<Vec<u8>>Serializes a serializable object into a Vec of bytes using this configuration
pub fn serialized_size<T: ?Sized + Serialize>(&self, t: &T) -> Result<u64>[src]
pub fn serialized_size<T: ?Sized + Serialize>(&self, t: &T) -> Result<u64>Returns the size that an object would be if serialized using Bincode with this configuration
pub fn serialize_into<W: Write, T: ?Sized + Serialize>(
&self,
w: W,
t: &T
) -> Result<()>[src]
pub fn serialize_into<W: Write, T: ?Sized + Serialize>(
&self,
w: W,
t: &T
) -> Result<()>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
pub fn deserialize<'a, T: Deserialize<'a>>(&self, bytes: &'a [u8]) -> Result<T>[src]
pub fn deserialize<'a, T: Deserialize<'a>>(&self, bytes: &'a [u8]) -> Result<T>Deserializes a slice of bytes into an instance of T using this configuration
pub fn deserialize_from<R: Read, T: DeserializeOwned>(
&self,
reader: R
) -> Result<T>[src]
pub fn deserialize_from<R: Read, T: DeserializeOwned>(
&self,
reader: R
) -> Result<T>Deserializes an object directly from a Reader using this configuration
If this returns an Error, reader may be in an invalid state.
pub fn deserialize_from_custom<'a, R: BincodeRead<'a>, T: DeserializeOwned>(
&self,
reader: R
) -> Result<T>[src]
pub fn deserialize_from_custom<'a, R: BincodeRead<'a>, T: DeserializeOwned>(
&self,
reader: R
) -> Result<T>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.
If this returns an Error, reader may be in an invalid state.
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T> From for T[src]
impl<T> From for Timpl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>try_from)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>try_from)Performs the conversion.
impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut TMutably borrows from an owned value. Read more
impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeId🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static
Gets the TypeId of self. Read more