Struct bytecodec::StartEncoderChain
[−]
[src]
pub struct StartEncoderChain;
An object for starting a chain of encoders.
Examples
use bytecodec::{Encode, EncodeBuf, EncodeExt, StartEncoderChain}; use bytecodec::bytes::Utf8Encoder; use bytecodec::fixnum::U8Encoder; let mut output = [0; 4]; let mut encoder = StartEncoderChain .chain(U8Encoder::new()) .chain(Utf8Encoder::new()) .map_from(|s: String| (s.len() as u8, s)); { encoder.start_encoding("foo".to_owned()).unwrap(); encoder.encode(&mut EncodeBuf::new(&mut output)).unwrap(); } assert_eq!(output.as_ref(), b"\x03foo");
Methods
impl StartEncoderChain[src]
pub fn chain<E: Encode>(&self, encoder: E) -> EncoderChain<Self, E, ()>[src]
Starts encoders chain.
Trait Implementations
impl Debug for StartEncoderChain[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more
impl Encode for StartEncoderChain[src]
type Item = ()
The type of items to be encoded.
fn encode(&mut self, _buf: &mut EncodeBuf) -> Result<()>[src]
Encodes the current item and writes the encoded bytes to the given buffer as many as possible. Read more
fn start_encoding(&mut self, _item: Self::Item) -> Result<()>[src]
Tries to start encoding the given item. Read more
fn is_idle(&self) -> bool[src]
Returns true if there are no items to be encoded in the encoder, otherwise false.
fn requiring_bytes_hint(&self) -> Option<u64>[src]
Returns the number of bytes required to encode all the items in the encoder. Read more
impl ExactBytesEncode for StartEncoderChain[src]
fn requiring_bytes(&self) -> u64[src]
Returns the number of bytes required to encode all the items in the encoder.