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§
sourceconst ENTRY: DecoderEntry<'a, T, R> = _
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§
sourcefn read_field(
item: &mut InplaceOption<'_, T>,
reader: FieldReader<'a, '_, R>,
) -> Result<(), Error>
fn read_field( item: &mut InplaceOption<'_, T>, reader: FieldReader<'a, '_, R>, ) -> Result<(), Error>
Reads a field into item
.
sourcefn default_field(item: &mut InplaceOption<'_, T>) -> Result<(), Error>
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§
sourcefn packed<'p, C>() -> Option<&'p dyn PackedDecode<'a, T, C>>where
C: CopyExtend<T>,
T: 'p,
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.
sourcefn wrap_in_sequence() -> bool
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).
sourcefn read_field_in_sequence(
item: &mut InplaceOption<'_, T>,
reader: FieldReader<'a, '_, R>,
) -> Result<(), Error>
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.