Struct bytecodec::bytes::BytesEncoder [] [src]

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

BytesEncoder writes the given bytes into an output byte sequence.

Examples

use bytecodec::{Encode, EncodeBuf, EncodeExt};
use bytecodec::bytes::BytesEncoder;

let mut output = [0; 4];
{
    let mut buf = EncodeBuf::new(&mut output);
    let mut encoder = BytesEncoder::with_item(b"foo").unwrap();
    encoder.encode(&mut buf).unwrap();
    assert!(encoder.is_idle());
    assert_eq!(buf.len(), 1);
}
assert_eq!(&output[..], b"foo\x00");

Methods

impl<B> BytesEncoder<B>
[src]

[src]

Makes a new BytesEncoder instance.

Trait Implementations

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

[src]

Formats the value using the given formatter. Read more

impl<B> Default for BytesEncoder<B>
[src]

[src]

Returns the "default value" for a type. Read more

impl<B: AsRef<[u8]>> Encode for BytesEncoder<B>
[src]

The type of items to be encoded.

[src]

Encodes the current item and writes the encoded bytes to the given buffer as many as possible. Read more

[src]

Tries to start encoding the given item. Read more

[src]

Returns the number of bytes required to encode all the items in the encoder. Read more

[src]

Returns true if there are no items to be encoded in the encoder, otherwise false.

impl<B: AsRef<[u8]>> ExactBytesEncode for BytesEncoder<B>
[src]

[src]

Returns the number of bytes required to encode all the items in the encoder.

Auto Trait Implementations

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

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