Struct bytecodec::combinator::Length
[−]
[src]
pub struct Length<C> { /* fields omitted */ }
Combinator for consuming the specified number of bytes exactly.
This is created by calling {DecodeExt, EncodeExt}::length
method.
Methods
impl<C> Length<C>
[src]
pub fn expected_bytes(&self) -> u64
[src]
Returns the number of bytes expected to be consumed for decoding an item.
pub fn set_expected_bytes(&mut self, bytes: u64) -> Result<()>
[src]
Sets the number of bytes expected to be consumed for decoding an item.
Errors
If it is in the middle of decoding an item, it willl return an ErrorKind::Other
error.
pub fn remaining_bytes(&self) -> u64
[src]
Returns the number of remaining bytes required to decode the next item.
ⓘImportant traits for &'a mut Wpub fn inner_ref(&self) -> &C
[src]
Returns a reference to the inner encoder or decoder.
ⓘImportant traits for &'a mut Wpub 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<C: Debug> Debug for Length<C>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<C: Default> Default for Length<C>
[src]
impl<D: Decode> Decode for Length<D>
[src]
type Item = D::Item
The type of items to be decoded.
fn decode(
&mut self,
buf: &[u8],
eos: Eos
) -> Result<(usize, Option<Self::Item>)>
[src]
&mut self,
buf: &[u8],
eos: Eos
) -> Result<(usize, Option<Self::Item>)>
Consumes the given buffer (a part of a byte sequence), and decodes an item from it. Read more
fn is_idle(&self) -> bool
[src]
Returns true
if there is no item being decoded by the decoder, otherwise false
.
fn requiring_bytes(&self) -> ByteCount
[src]
Returns the lower bound of the number of bytes needed to decode the next item. Read more
impl<E: Encode> Encode for Length<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]
Encodes the items in the encoder and writes the encoded bytes to the given buffer. Read more
fn start_encoding(&mut self, item: Self::Item) -> Result<()>
[src]
Tries to start encoding the given item. Read more
fn requiring_bytes(&self) -> ByteCount
[src]
Returns the number of bytes required to encode all the items in the encoder. Read more
fn is_idle(&self) -> bool
[src]
Returns true
if there are no items to be encoded in the encoder, otherwise false
.
impl<E: Encode> ExactBytesEncode for Length<E>
[src]
fn exact_requiring_bytes(&self) -> u64
[src]
Returns the exact number of bytes required to encode all the items remaining in the encoder.