pub struct FieldDescriptor { /* private fields */ }Expand description
Handle to one field in a MessageDescriptor.
Implementations§
Source§impl FieldDescriptor
impl FieldDescriptor
Sourcepub fn json_name(&self) -> &str
pub fn json_name(&self) -> &str
JSON field name (lower-camelCase by default; honors a user-supplied
json_name option when present).
Sourcepub fn cardinality(&self) -> Cardinality
pub fn cardinality(&self) -> Cardinality
Optional, Required, or Repeated.
Sourcepub fn supports_presence(&self) -> bool
pub fn supports_presence(&self) -> bool
True iff the wire format tracks presence for this field (proto2
scalars, message-typed fields, oneof members, proto3 optional).
Sourcepub fn is_packable(&self) -> bool
pub fn is_packable(&self) -> bool
True iff this field’s Kind admits packed encoding (scalar or
enum) — independent of whether is_packed() is currently set.
Sourcepub fn is_list(&self) -> bool
pub fn is_list(&self) -> bool
True iff this is a repeated (non-map) field.
Note that map<K, V> fields are technically also repeated on
the wire, but their value model is crate::Value::Map, not
crate::Value::List — this helper returns false for maps.
Sourcepub fn parsed_default_value(&self) -> Option<Value>
Available on crate feature dynamic only.
pub fn parsed_default_value(&self) -> Option<Value>
dynamic only.Pre-parsed [default = ...] value, if the field carried one.
Available for any scalar / enum / string / bytes field whose
proto declared an explicit default. None for proto3 fields,
for repeated fields, and for fields without an explicit default.
Sourcepub fn is_map(&self) -> bool
pub fn is_map(&self) -> bool
True iff this field models a map<K, V>.
A field is a map iff its kind is a message that carries the
map_entry = true option.
Sourcepub fn containing_oneof(&self) -> Option<OneofDescriptor>
pub fn containing_oneof(&self) -> Option<OneofDescriptor>
Containing oneof, when this field is part of one.
Sourcepub fn parent_message(&self) -> MessageDescriptor
pub fn parent_message(&self) -> MessageDescriptor
Owning message.
Sourcepub fn descriptor_proto(&self) -> &FieldDescriptorProto
pub fn descriptor_proto(&self) -> &FieldDescriptorProto
Raw FieldDescriptorProto for advanced use.
Trait Implementations§
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