Skip to main content

BincodeLen

Struct BincodeLen 

Source
pub struct BincodeLen<const MAX_SIZE: usize = DEFAULT_BINCODE_LEN_MAX_SIZE>;
Expand description

SeqLen implementation for bincode’s default fixint encoding.

The MAX_SIZE constant is a limit on the maximum preallocation size (in bytes) for heap allocated structures. This is a safety precaution against malicious input causing OOM. The default is 4 MiB. Users are free to override this limit by passing a different constant or by implementing their own SeqLen implementation.

Trait Implementations§

Source§

impl<const MAX_SIZE: usize> SeqLen for BincodeLen<MAX_SIZE>

Source§

fn read<'de, T>(reader: &mut impl Reader<'de>) -> ReadResult<usize>

Read the length of a sequence from the reader, where T is the type of the sequence elements. This can be used to enforce size constraints for preallocations. Read more
Source§

fn write(writer: &mut impl Writer, len: usize) -> WriteResult<()>

Write the length of a sequence to the writer.
Source§

fn write_bytes_needed(_len: usize) -> WriteResult<usize>

Calculate the number of bytes needed to write the given length. Read more

Auto Trait Implementations§

§

impl<const MAX_SIZE: usize> Freeze for BincodeLen<MAX_SIZE>

§

impl<const MAX_SIZE: usize> RefUnwindSafe for BincodeLen<MAX_SIZE>

§

impl<const MAX_SIZE: usize> Send for BincodeLen<MAX_SIZE>

§

impl<const MAX_SIZE: usize> Sync for BincodeLen<MAX_SIZE>

§

impl<const MAX_SIZE: usize> Unpin for BincodeLen<MAX_SIZE>

§

impl<const MAX_SIZE: usize> UnsafeUnpin for BincodeLen<MAX_SIZE>

§

impl<const MAX_SIZE: usize> UnwindSafe for BincodeLen<MAX_SIZE>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.