Struct bytecodec::bytes::RemainingBytesDecoder [−][src]
pub struct RemainingBytesDecoder { /* fields omitted */ }
RemainingBytesDecoder
reads all the bytes from a input sequence until it reaches EOS.
Examples
use bytecodec::{Decode, Eos}; use bytecodec::bytes::RemainingBytesDecoder; let mut decoder = RemainingBytesDecoder::new(); assert_eq!(decoder.requiring_bytes().to_u64(), None); let size = decoder.decode(b"foo", Eos::new(false)).unwrap(); assert_eq!(size, 3); assert_eq!(decoder.is_idle(), false); let size = decoder.decode(b"bar", Eos::new(true)).unwrap(); assert_eq!(size, 3); assert_eq!(decoder.is_idle(), true); assert_eq!(decoder.finish_decoding().unwrap(), b"foobar");
Methods
impl RemainingBytesDecoder
[src]
impl RemainingBytesDecoder
Trait Implementations
impl Debug for RemainingBytesDecoder
[src]
impl Debug for RemainingBytesDecoder
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Default for RemainingBytesDecoder
[src]
impl Default for RemainingBytesDecoder
fn default() -> RemainingBytesDecoder
[src]
fn default() -> RemainingBytesDecoder
Returns the "default value" for a type. Read more
impl Decode for RemainingBytesDecoder
[src]
impl Decode for RemainingBytesDecoder
type Item = Vec<u8>
The type of items to be decoded.
fn decode(&mut self, buf: &[u8], eos: Eos) -> Result<usize>
[src]
fn decode(&mut self, buf: &[u8], eos: Eos) -> Result<usize>
Consumes the given buffer (a part of a byte sequence), and proceeds the decoding process. Read more
fn finish_decoding(&mut self) -> Result<Self::Item>
[src]
fn finish_decoding(&mut self) -> Result<Self::Item>
Finishes the current decoding process and returns the decoded item. Read more
fn requiring_bytes(&self) -> ByteCount
[src]
fn requiring_bytes(&self) -> ByteCount
Returns the lower bound of the number of bytes needed to decode the next item. Read more
fn is_idle(&self) -> bool
[src]
fn is_idle(&self) -> bool
Returns true
if there are no items to be decoded by the decoder at the next invocation of decode
method, otherwise false
. Read more
Auto Trait Implementations
impl Send for RemainingBytesDecoder
impl Send for RemainingBytesDecoder
impl Sync for RemainingBytesDecoder
impl Sync for RemainingBytesDecoder