Struct bytecodec::bytes::BytesDecoder [] [src]

pub struct BytesDecoder<B> { /* fields omitted */ }

BytesDecoder copies bytes from an input sequence to a slice.

This is a oneshot decoder (i.e., it decodes only one item).

Examples

use bytecodec::{Decode, DecodeBuf};
use bytecodec::bytes::BytesDecoder;

let mut decoder = BytesDecoder::new([0; 3]);
assert_eq!(decoder.requiring_bytes_hint(), Some(3));

let mut input = DecodeBuf::new(b"foobar");
let item = decoder.decode(&mut input).unwrap();
assert_eq!(item.as_ref(), Some(b"foo"));
assert_eq!(decoder.requiring_bytes_hint(), Some(0)); // no more items are decoded

Methods

impl<B> BytesDecoder<B>
[src]

[src]

Makes a new BytesDecoder instance for filling the given byte slice.

Trait Implementations

impl<B: Debug> Debug for BytesDecoder<B>
[src]

[src]

Formats the value using the given formatter. Read more

impl<B: AsRef<[u8]> + AsMut<[u8]>> Decode for BytesDecoder<B>
[src]

The type of items to be decoded.

[src]

Consumes the given buffer (a part of a byte sequence), and decodes an item from it. Read more

[src]

Returns true if the decoder cannot decode items anymore, otherwise false. Read more

[src]

Returns true if the decoder does not have an item that being decoded, otherwise false.

[src]

Returns the lower bound of the number of bytes needed to decode the next item. Read more

Auto Trait Implementations

impl<B> Send for BytesDecoder<B> where
    B: Send

impl<B> Sync for BytesDecoder<B> where
    B: Sync