[][src]Struct bytecodec::combinator::MaxBytes

pub struct MaxBytes<C> { /* fields omitted */ }

Combinator that will fail if the number of consumed bytes exceeds the specified size.

This is created by calling {DecodeExt, EncodeExt}::max_bytes method.

Note that MaxBytes assumes the inner decoder will consume all the bytes in the target stream.

Methods

impl<C> MaxBytes<C>[src]

pub fn consumed_bytes(&self) -> u64[src]

Returns the number of bytes consumed for encoding/decoding the current item.

pub fn max_bytes(&self) -> u64[src]

Returns the maximum number of bytes that can be consumed for encoding/decoding an item.

pub fn set_max_bytes(&mut self, n: u64) -> Result<()>[src]

Sets the maximum number of bytes that can be consumed for encoding/decoding an item.

Error

If n is smaller than self.consumed_bytes(), an ErrorKind::InvalidInput error will be returned.

pub fn inner_ref(&self) -> &C[src]

Returns a reference to the inner encoder or decoder.

pub fn inner_mut(&mut self) -> &mut C[src]

Returns a mutable reference to the inner encoder or decoder.

pub fn into_inner(self) -> C[src]

Takes ownership of this instance and returns the inner encoder or decoder.

Trait Implementations

impl<D: Decode> Decode for MaxBytes<D>[src]

type Item = D::Item

The type of items to be decoded.

impl<E: Encode> Encode for MaxBytes<E>[src]

type Item = E::Item

The type of items to be encoded.

impl<E: SizedEncode> SizedEncode for MaxBytes<E>[src]

impl<C: Default> Default for MaxBytes<C>[src]

impl<C: Debug> Debug for MaxBytes<C>[src]

Auto Trait Implementations

impl<C> Send for MaxBytes<C> where
    C: Send

impl<C> Unpin for MaxBytes<C> where
    C: Unpin

impl<C> Sync for MaxBytes<C> where
    C: Sync

impl<C> UnwindSafe for MaxBytes<C> where
    C: UnwindSafe

impl<C> RefUnwindSafe for MaxBytes<C> where
    C: RefUnwindSafe

Blanket Implementations

impl<T> IoDecodeExt for T where
    T: Decode
[src]

impl<T> IoEncodeExt for T where
    T: Encode
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]