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