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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.