Struct protobuf_codec::field::Optional
[−]
[src]
pub struct Optional<T>(_);
Decoder and encoder for optinal fields.
Methods
impl<T> Optional<T>
[src]
pub fn new(inner: T) -> Self
[src]
Makes a new Optional
instance.
pub fn inner_ref(&self) -> &T
[src]
Returns a reference to the inner field encoder/decoder.
pub fn inner_mut(&mut self) -> &mut T
[src]
Returns a mutable reference to the inner field encoder/decoder.
pub fn into_inner(self) -> T
[src]
Takes the ownership of the instance, and returns the inner field encoder/decoder.
Trait Implementations
impl<T: Debug> Debug for Optional<T>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<T: Default> Default for Optional<T>
[src]
impl<D: RequiredFieldDecode> Decode for Optional<D>
[src]
type Item = Option<D::Item>
The type of items to be decoded.
fn decode(&mut self, buf: &[u8], eos: Eos) -> Result<usize>
[src]
Consumes the given buffer (a part of a byte sequence), and proceeds the decoding process. Read more
fn is_idle(&self) -> bool
[src]
Returns true
if there are no items to be decoded by the decoder at the next invocation of decode
method, otherwise false
. Read more
fn finish_decoding(&mut self) -> Result<Self::Item>
[src]
Finishes the current decoding process and returns the decoded item. Read more
fn requiring_bytes(&self) -> ByteCount
[src]
Returns the lower bound of the number of bytes needed to decode the next item. Read more
impl<D: RequiredFieldDecode> FieldDecode for Optional<D>
[src]
fn start_decoding(&mut self, tag: Tag) -> Result<bool>
[src]
Tries to start decoding a field. Read more
impl<E: RequiredFieldEncode> Encode for Optional<E>
[src]
type Item = Option<E::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
. Read more
fn requiring_bytes(&self) -> ByteCount
[src]
Returns the number of bytes required to encode all the items in the encoder. Read more
impl<E: RequiredFieldEncode + SizedEncode> SizedEncode for Optional<E>
[src]
fn exact_requiring_bytes(&self) -> u64
[src]
Returns the exact number of bytes required to encode all the items remaining in the encoder.