pub struct EncoderLenEstimator { /* private fields */ }
Expand description

Estimates the encoding_size of an EncoderValue

Implementations§

source§

impl EncoderLenEstimator

source

pub const fn new(capacity: usize) -> Self

Create a new estimator with a given buffer capacity

source

pub const fn overflowed(&self) -> bool

Returns true when the estimated len is greater than the allocated buffer capacity.

Trait Implementations§

source§

impl Encoder for EncoderLenEstimator

source§

fn write_sized<F: FnOnce(&mut [u8])>(&mut self, len: usize, _write: F)

Calls write with a slice of len bytes at the current write position
source§

fn write_slice(&mut self, slice: &[u8])

Copies the slice into the buffer
source§

fn write_repeated(&mut self, count: usize, _value: u8)

Repeatedly write a byte value for a given count Read more
source§

fn write_zerocopy<T: FromBytes + Unaligned, F: FnOnce(&mut T)>( &mut self, _write: F )

Writes a zerocopy value to the buffer
source§

fn capacity(&self) -> usize

Returns the total buffer capacity
source§

fn len(&self) -> usize

Returns the number of bytes written to the buffer
source§

const SPECIALIZES_BYTES: bool = false

Set to true if the particular encoder specializes on the bytes implementation
source§

fn encode<T: EncoderValue>(&mut self, value: &T)

Encode the given EncoderValue into the buffer
source§

fn encode_with_len_prefix<Len: TryFrom<usize> + EncoderValue, T: EncoderValue>( &mut self, value: &T )where Len::Error: Debug,

Encode the given EncoderValue into the buffer with a prefix of Len
source§

fn write_bytes(&mut self, bytes: Bytes)

source§

fn is_empty(&self) -> bool

Returns true if no bytes have been written
source§

fn remaining_capacity(&self) -> usize

Returns the number of available bytes in the buffer

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.