Struct protobuf_codec::field::MaybeDefault [] [src]

pub struct MaybeDefault<T>(_);

Decoder and encoder for optional fields which have the default values.

If a field is missing in a target input stream, the default value is used as the field value instead.

Methods

impl<T> MaybeDefault<T>
[src]

[src]

Makes a new MaybeDefault instance.

[src]

Returns a reference to the inner field encoder/decoder.

[src]

Returns a mutable reference to the inner field encoder/decoder.

[src]

Takes the ownership of the instance, and returns the inner field encoder/decoder.

Trait Implementations

impl<T: Debug> Debug for MaybeDefault<T>
[src]

[src]

Formats the value using the given formatter. Read more

impl<T: Default> Default for MaybeDefault<T>
[src]

[src]

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

impl<D> Decode for MaybeDefault<D> where
    D: RequiredFieldDecode,
    D::Item: Default
[src]

The type of items to be decoded.

[src]

Consumes the given buffer (a part of a byte sequence), and proceeds the decoding process. Read more

[src]

Finishes the current decoding process and returns the decoded item. Read more

[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

[src]

Returns the lower bound of the number of bytes needed to decode the next item. Read more

impl<D> FieldDecode for MaybeDefault<D> where
    D: RequiredFieldDecode,
    D::Item: Default
[src]

[src]

Tries to start decoding a field. Read more

impl<E> Encode for MaybeDefault<E> where
    E: RequiredFieldEncode,
    E::Item: Default + PartialEq
[src]

The type of items to be encoded.

[src]

Encodes the items in the encoder and writes the encoded bytes to the given buffer. Read more

[src]

Tries to start encoding the given item. Read more

[src]

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

[src]

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

impl<E> SizedEncode for MaybeDefault<E> where
    E: RequiredFieldEncode + SizedEncode,
    E::Item: Default + PartialEq
[src]

[src]

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

impl<E> FieldEncode for MaybeDefault<E> where
    E: RequiredFieldEncode,
    E::Item: Default + PartialEq
[src]

Auto Trait Implementations

impl<T> Send for MaybeDefault<T> where
    T: Send

impl<T> Sync for MaybeDefault<T> where
    T: Sync