Trait mesh::payload::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<(), Error>;
    fn default_field(item: &mut InplaceOption<'_, T>) -> Result<(), Error>;

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

Reads a field into item.

source

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

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>() -> Option<&'p dyn PackedDecode<'a, T, C>>
where C: CopyExtend<T>, 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<(), Error>

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> FieldDecode<'a, T, R> for BytesField
where T: From<&'a [u8]> + Default,

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

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<R> FieldDecode<'_, u128, R> for U128LittleEndianField

source§

impl<T, R> FieldDecode<'_, T, R> for PortField
where T: From<Port>, Port: TryFrom<R>, <Port as TryFrom<R>>::Error: 'static + Error + Send + Sync,

source§

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

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 as TryFrom<R>>::Error: 'static + Error + Send + Sync,