Struct bytecodec::StartDecoderChain
[−]
[src]
pub struct StartDecoderChain;
An object for starting a chain of decoders.
Examples
use bytecodec::{Decode, DecodeExt, StartDecoderChain}; use bytecodec::fixnum::U8Decoder; use bytecodec::io::IoDecodeExt; let mut decoder = StartDecoderChain .chain(U8Decoder::new()) .chain(U8Decoder::new()) .chain(U8Decoder::new()); let mut input = &b"foobar"[..]; let item = decoder.decode_exact(&mut input).unwrap(); assert_eq!(item, (b'f', b'o', b'o')); let item = decoder.decode_exact(&mut input).unwrap(); assert_eq!(item, (b'b', b'a', b'r'));
Methods
impl StartDecoderChain
[src]
pub fn chain<D: Decode>(&self, decoder: D) -> DecoderChain<Self, D, ()>
[src]
Starts decoders chain.
Trait Implementations
impl Debug for StartDecoderChain
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Decode for StartDecoderChain
[src]
type 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 has_terminated(&self) -> bool
[src]
Returns true
if the decoder cannot decode items anymore, otherwise false
. Read more
fn requiring_bytes(&self) -> ByteCount
[src]
Returns the lower bound of the number of bytes needed to decode the next item. Read more