Struct bytecodec::StartEncoderChain
[−]
[src]
pub struct StartEncoderChain;
An object for starting a chain of encoders.
Examples
use bytecodec::{Encode, EncodeExt, StartEncoderChain}; use bytecodec::bytes::Utf8Encoder; use bytecodec::fixnum::U8Encoder; use bytecodec::io::IoEncodeExt; let mut output = Vec::new(); 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_all(&mut output).unwrap(); assert_eq!(output, 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 [u8], _eos: Eos) -> Result<usize>
[src]
Encodes the items in the encoder and writes the encoded bytes to the given buffer. 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(&self) -> ByteCount
[src]
Returns the number of bytes required to encode all the items in the encoder. Read more
impl ExactBytesEncode for StartEncoderChain
[src]
fn exact_requiring_bytes(&self) -> u64
[src]
Returns the exact number of bytes required to encode all the items remaining in the encoder.