Trait mesh_protobuf::FieldDecode

source ·
pub trait FieldDecode<'a, T, R>: Sized {
    const ENTRY: DecoderEntry<'a, T, R> = _;

    // Required methods
    fn read_field(
        item: &mut InplaceOption<'_, T>,
        reader: FieldReader<'a, '_, R>,
    ) -> Result<()>;
    fn default_field(item: &mut InplaceOption<'_, T>) -> Result<()>;

    // Provided methods
    fn packed<'p, C: CopyExtend<T>>() -> Option<&'p dyn PackedDecode<'a, T, C>>
       where T: 'p { ... }
    fn wrap_in_sequence() -> bool { ... }
    fn read_field_in_sequence(
        item: &mut InplaceOption<'_, T>,
        reader: FieldReader<'a, '_, R>,
    ) -> Result<()> { ... }
}
Expand description

The FieldEncode trait provides a field decoder for type T.

R is the external resource type, which allows decoding objects with non-protobuf resources such as file descriptors. Most implementors of this trait will be generic over all R.

Provided Associated Constants§

source

const ENTRY: DecoderEntry<'a, T, R> = _

The table decoder entry for this type, used in types from table::decode.

This should not be overridden by implementations.

Required Methods§

source

fn read_field( item: &mut InplaceOption<'_, T>, reader: FieldReader<'a, '_, R>, ) -> Result<()>

Reads a field into item.

source

fn default_field(item: &mut InplaceOption<'_, T>) -> Result<()>

Instantiates item with its default value, if there is one.

If an implementation returns Ok(()), then it must have set an item. Callers of this method may panic otherwise.

Provided Methods§

source

fn packed<'p, C: CopyExtend<T>>() -> Option<&'p dyn PackedDecode<'a, T, C>>
where T: 'p,

Unless packed()::must_pack() is true, the sequence decoder must detect the encoding (packed or not) and call the appropriate method.

source

fn wrap_in_sequence() -> bool

Returns whether this field is wrapped in a message when encoded nested in a sequence (such as a repeated field).

source

fn read_field_in_sequence( item: &mut InplaceOption<'_, T>, reader: FieldReader<'a, '_, R>, ) -> Result<()>

Reads this field that was encoded as part of a sequence, unwrapping it from a message if necessary.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'a, 'b, R> FieldDecode<'a, Cow<'b, str>, R> for OwningCowField

source§

impl<'a, 'b, R> FieldDecode<'a, Cow<'b, [u8]>, R> for OwningCowField

source§

impl<'a, K, V, T, EK, EV, R> FieldDecode<'a, T, R> for MapField<K, V, EK, EV>
where T: Default + Extend<(K, V)>, EK: FieldDecode<'a, K, R>, EV: FieldDecode<'a, V, R>,

source§

impl<'a, R> FieldDecode<'a, Cow<'a, str>, R> for BorrowedCowField

source§

impl<'a, R> FieldDecode<'a, Cow<'a, [u8]>, R> for BorrowedCowField

source§

impl<'a, R> FieldDecode<'a, u8, R> for ByteField

source§

impl<'a, T, R, E: FieldDecode<'a, T, R>> FieldDecode<'a, Option<T>, R> for OptionField<E>

source§

impl<'a, T, R, E: FieldDecode<'a, T, R>> FieldDecode<'a, Box<T>, R> for BoxEncoding<E>

source§

impl<'a, T, R, E: FieldDecode<'a, T, R>> FieldDecode<'a, Vec<T>, R> for VecField<E>

source§

impl<'a, T, R, E: FieldDecode<'a, T, R>, const N: usize> FieldDecode<'a, [T; N], R> for ArrayField<E>

source§

impl<'a, T, R, E: MessageDecode<'a, T, R>> FieldDecode<'a, T, R> for MessageEncoding<E>

source§

impl<'a, T: FixedNumber<Type = u32>, R> FieldDecode<'a, T, R> for Fixed32Field

source§

impl<'a, T: FixedNumber<Type = u64>, R> FieldDecode<'a, T, R> for Fixed64Field

source§

impl<'a, T: FromNumber, R> FieldDecode<'a, T, R> for SignedVarintField

source§

impl<'a, T: FromNumber, R> FieldDecode<'a, T, R> for VarintField

source§

impl<'a, T: Clone, R, E: FieldDecode<'a, T, R>> FieldDecode<'a, Arc<T>, R> for ArcEncoding<E>

source§

impl<'a, T: From<&'a str> + Default, R> FieldDecode<'a, T, R> for StringField

source§

impl<'a, T: From<&'a [u8]> + Default, R> FieldDecode<'a, T, R> for BytesField

source§

impl<'a, T: FromBytes, R> FieldDecode<'a, T, R> for ZeroCopyEncoding

source§

impl<'de, T, R> FieldDecode<'de, T, R> for TableEncoder
where T: StructDecodeMetadata<'de, R>,

source§

const ENTRY: DecoderEntry<'de, T, R> = _

source§

impl<'de, T: OneofDecode<'de, R>, R> FieldDecode<'de, T, R> for OneofEncoder

source§

impl<'de, T: Transparent, E: FieldDecode<'de, T::Inner, R>, R> FieldDecode<'de, T, R> for TransparentEncoding<E>

source§

const ENTRY: DecoderEntry<'de, T, R> = _

source§

impl<R> FieldDecode<'_, u128, R> for U128LittleEndianField

source§

impl<T, R> FieldDecode<'_, T, R> for ImpossibleField

source§

impl<T, U, R> FieldDecode<'_, T, R> for ResourceField<U>
where T: From<U>, U: TryFrom<R>, U::Error: 'static + Error + Send + Sync,

source§

impl<T: Default, R> FieldDecode<'_, T, R> for IgnoreField