pub struct FieldDescriptor { /* private fields */ }Expand description
A linked, feature-resolved field descriptor.
Constructed only by DescriptorPool; not
constructible by downstream crates. The fields are accessed through
methods so the pool can change its internal representation without
breaking consumers.
Implementations§
Source§impl FieldDescriptor
impl FieldDescriptor
Sourcepub fn json_name(&self) -> &str
pub fn json_name(&self) -> &str
JSON name — lowerCamelCase unless overridden by [json_name = ...].
Sourcepub fn presence(&self) -> FieldPresence
pub fn presence(&self) -> FieldPresence
Resolved presence discipline. For List/Map kinds this is always
Implicit (repeated fields have no presence).
Sourcepub fn is_packed(&self) -> bool
pub fn is_packed(&self) -> bool
Whether a List of packable scalars uses packed wire encoding.
Meaningless for non-list or non-packable kinds.
Sourcepub fn is_delimited(&self) -> bool
pub fn is_delimited(&self) -> bool
Whether a Message kind uses delimited (group-style) wire encoding.
Meaningless for non-message kinds.
Sourcepub fn oneof_index(&self) -> Option<u16>
pub fn oneof_index(&self) -> Option<u16>
Index into the parent message’s oneofs,
if this field belongs to a oneof (including proto3 synthetic oneofs
for optional).
Sourcepub fn options(&self) -> Option<&FieldOptions>
pub fn options(&self) -> Option<&FieldOptions>
The raw FieldOptions for this field, if any were declared.
Standard options (deprecated, etc.) read directly off the returned
struct. Custom options — [(my.pkg.opt) = ...] — are extensions
of google.protobuf.FieldOptions; they survive on the returned
struct’s unknown fields. To read one generically, register the
option’s defining proto (and descriptor.proto) in the same pool,
then reflect over the options via
DynamicMessage::from_options:
let dyn_opts = DynamicMessage::from_options(Arc::clone(&pool), field.options()?)?;
let ext = pool.extension_by_name("my.pkg.opt")?;
let value = dyn_opts.get(ext.field());Trait Implementations§
Source§impl AsRef<FieldDescriptor> for ExtensionDescriptor
impl AsRef<FieldDescriptor> for ExtensionDescriptor
Source§fn as_ref(&self) -> &FieldDescriptor
fn as_ref(&self) -> &FieldDescriptor
Equivalent to field(), for generic code that accepts
“anything that is a field descriptor”.
Source§impl Clone for FieldDescriptor
impl Clone for FieldDescriptor
Source§fn clone(&self) -> FieldDescriptor
fn clone(&self) -> FieldDescriptor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more