Struct bytecodec::combinator::MaxBytes [−][src]
pub struct MaxBytes<C> { /* fields omitted */ }
Expand description
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.
Implementations
Returns the number of bytes consumed for encoding/decoding the current item.
Returns the maximum number of bytes that can be consumed for encoding/decoding an item.
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.
Returns a mutable reference to the inner encoder or decoder.
Takes ownership of this instance and returns the inner encoder or decoder.
Trait Implementations
Returns the exact number of bytes required to encode all the items remaining in the encoder.
Auto Trait Implementations
impl<C> RefUnwindSafe for MaxBytes<C> where
C: RefUnwindSafe,
impl<C> UnwindSafe for MaxBytes<C> where
C: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Encodes the items remaining in the encoder and writes the encoded bytes to the given write buffer. Read more
Encodes the items remaining in the encoder and
writes the encoded bytes to the given write buffer.
If the write buffer is full and the writing cannot be performed,
the given WriteBuf will memorize cx’s Waker
.
This Waker
’s wake
will later be called when the WriteBuf
regains its free space. Read more