pub struct CounterUnpacker<U: Unpacker> { /* private fields */ }
Expand description

An Unpacker able to keep count of the number of read bytes.

Implementations§

source§

impl<U: Unpacker> CounterUnpacker<U>

source

pub fn new(unpacker: U) -> Self

Creates a new CounterUnpacker.

source

pub fn counter(&self) -> usize

Returns the number of read bytes.

source

pub fn into_inner(self) -> U

Consumes the value to return the inner Unpacker.

Trait Implementations§

source§

impl<U: Unpacker> Unpacker for CounterUnpacker<U>

§

type Error = <U as Unpacker>::Error

An error type representing any error related to reading bytes.
source§

fn unpack_bytes<B: AsMut<[u8]>>(&mut self, bytes: B) -> Result<(), Self::Error>

Reads a sequence of bytes from the Unpacker. This sequence must be long enough to fill bytes completely. This method must fail if the unpacker does not have enough bytes to fulfill the request.
source§

fn ensure_bytes(&self, len: usize) -> Result<(), Self::Error>

Tries to guarantee that the Unpacker has at least len bytes. Read more
source§

fn read_bytes(&self) -> Option<usize>

Returns the exact number of read bytes if possible.

Auto Trait Implementations§

§

impl<U> RefUnwindSafe for CounterUnpacker<U>
where U: RefUnwindSafe,

§

impl<U> Send for CounterUnpacker<U>
where U: Send,

§

impl<U> Sync for CounterUnpacker<U>
where U: Sync,

§

impl<U> Unpin for CounterUnpacker<U>
where U: Unpin,

§

impl<U> UnwindSafe for CounterUnpacker<U>
where U: UnwindSafe,

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>,

§

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>,

§

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.