Struct bytecodec::combinator::Optional [−][src]
pub struct Optional<E>(_);
Combinator for representing an optional encoder.
Methods
impl<E> Optional<E>[src]
impl<E> Optional<E>ⓘImportant traits for &'a mut Rpub fn inner_ref(&self) -> &E[src]
ⓘImportant traits for &'a mut R
pub fn inner_ref(&self) -> &EReturns a reference to the inner encoder.
ⓘImportant traits for &'a mut Rpub fn inner_mut(&mut self) -> &mut E[src]
ⓘImportant traits for &'a mut R
pub fn inner_mut(&mut self) -> &mut EReturns a mutable reference to the inner encoder.
pub fn into_inner(self) -> E[src]
pub fn into_inner(self) -> ETakes ownership of this instance and returns the inner encoder.
Trait Implementations
impl<E: Debug> Debug for Optional<E>[src]
impl<E: Debug> Debug for Optional<E>fn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl<E: Default> Default for Optional<E>[src]
impl<E: Default> Default for Optional<E>impl<E: Encode> Encode for Optional<E>[src]
impl<E: Encode> Encode for Optional<E>type Item = Option<E::Item>
The type of items to be encoded.
fn encode(&mut self, buf: &mut [u8], eos: Eos) -> Result<usize>[src]
fn encode(&mut self, buf: &mut [u8], eos: Eos) -> Result<usize>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]
fn start_encoding(&mut self, item: Self::Item) -> Result<()>Tries to start encoding the given item. Read more
fn requiring_bytes(&self) -> ByteCount[src]
fn requiring_bytes(&self) -> ByteCountReturns the number of bytes required to encode all the items in the encoder. Read more
fn is_idle(&self) -> bool[src]
fn is_idle(&self) -> boolReturns true if there are no items to be encoded in the encoder, otherwise false. Read more
impl<E: SizedEncode> SizedEncode for Optional<E>[src]
impl<E: SizedEncode> SizedEncode for Optional<E>fn exact_requiring_bytes(&self) -> u64[src]
fn exact_requiring_bytes(&self) -> u64Returns the exact number of bytes required to encode all the items remaining in the encoder.