[−][src]Struct bytecodec::combinator::MaxBytes
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.
fn decode(&mut self, buf: &[u8], eos: Eos) -> Result<usize>
[src]
fn finish_decoding(&mut self) -> Result<Self::Item>
[src]
fn requiring_bytes(&self) -> ByteCount
[src]
fn is_idle(&self) -> bool
[src]
impl<E: Encode> Encode for MaxBytes<E>
[src]
type Item = E::Item
The type of items to be encoded.
fn encode(&mut self, buf: &mut [u8], eos: Eos) -> Result<usize>
[src]
fn start_encoding(&mut self, item: Self::Item) -> Result<()>
[src]
fn requiring_bytes(&self) -> ByteCount
[src]
fn is_idle(&self) -> bool
[src]
impl<E: SizedEncode> SizedEncode for MaxBytes<E>
[src]
fn exact_requiring_bytes(&self) -> u64
[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,
C: Send,
impl<C> Unpin for MaxBytes<C> where
C: Unpin,
C: Unpin,
impl<C> Sync for MaxBytes<C> where
C: Sync,
C: Sync,
impl<C> UnwindSafe for MaxBytes<C> where
C: UnwindSafe,
C: UnwindSafe,
impl<C> RefUnwindSafe for MaxBytes<C> where
C: RefUnwindSafe,
C: RefUnwindSafe,
Blanket Implementations
impl<T> IoDecodeExt for T where
T: Decode,
[src]
T: Decode,
fn decode_from_read_buf<B>(&mut self, buf: &mut ReadBuf<B>) -> Result<()> where
B: AsRef<[u8]>,
[src]
B: AsRef<[u8]>,
fn decode_exact<R: Read>(&mut self, reader: R) -> Result<Self::Item>
[src]
impl<T> IoEncodeExt for T where
T: Encode,
[src]
T: Encode,
fn encode_to_write_buf<B>(&mut self, buf: &mut WriteBuf<B>) -> Result<()> where
B: AsMut<[u8]>,
[src]
B: AsMut<[u8]>,
fn encode_all<W: Write>(&mut self, writer: W) -> Result<()>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,