pub struct FieldDescriptorProto {
pub name: Option<String>,
pub number: Option<i32>,
pub label: Option<EnumOrUnknown<Label>>,
pub type_: Option<EnumOrUnknown<Type>>,
pub type_name: Option<String>,
pub extendee: Option<String>,
pub default_value: Option<String>,
pub oneof_index: Option<i32>,
pub json_name: Option<String>,
pub options: MessageField<FieldOptions>,
pub proto3_optional: Option<bool>,
pub special_fields: SpecialFields,
}
Expand description
Describes a field within a message.
Fields§
§name: Option<String>
§number: Option<i32>
§label: Option<EnumOrUnknown<Label>>
§type_: Option<EnumOrUnknown<Type>>
If type_name is set, this need not be set. If both this and type_name are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
type_name: Option<String>
For message and enum types, this is the name of the type. If the name starts with a ‘.’, it is fully-qualified. Otherwise, C++-like scoping rules are used to find the type (i.e. first the nested types within this message are searched, then within the parent, on up to the root namespace).
extendee: Option<String>
For extensions, this is the name of the type being extended. It is resolved in the same manner as type_name.
default_value: Option<String>
For numeric types, contains the original text representation of the value. For booleans, “true” or “false”. For strings, contains the default text contents (not escaped in any way). For bytes, contains the C escaped value. All bytes >= 128 are escaped. TODO(kenton): Base-64 encode?
oneof_index: Option<i32>
If set, gives the index of a oneof in the containing type’s oneof_decl list. This field is a member of that oneof.
json_name: Option<String>
JSON name of this field. The value is set by protocol compiler. If the user has set a “json_name” option on this field, that option’s value will be used. Otherwise, it’s deduced from the field’s name by converting it to camelCase.
options: MessageField<FieldOptions>
§proto3_optional: Option<bool>
If true, this is a proto3 “optional”. When a proto3 field is optional, it tracks presence regardless of field type.
When proto3_optional is true, this field must be belong to a oneof to signal to old proto3 clients that presence is tracked for this field. This oneof is known as a “synthetic” oneof, and this field must be its sole member (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs exist in the descriptor only, and do not generate any API. Synthetic oneofs must be ordered after all “real” oneofs.
For message fields, proto3_optional doesn’t create any semantic change, since non-repeated message fields always track presence. However it still indicates the semantic detail of whether the user wrote “optional” or not. This can be useful for round-tripping the .proto file. For consistency we give message fields a synthetic oneof also, even though it is not required to track presence. This is especially important because the parser can’t tell if a field is a message or an enum, so it must always create a synthetic oneof.
Proto2 optional fields do not set this flag, because they already indicate
optional with LABEL_OPTIONAL
.
special_fields: SpecialFields
Implementations§
Source§impl FieldDescriptorProto
impl FieldDescriptorProto
pub fn new() -> FieldDescriptorProto
pub fn name(&self) -> &str
pub fn clear_name(&mut self)
pub fn has_name(&self) -> bool
pub fn set_name(&mut self, v: String)
pub fn mut_name(&mut self) -> &mut String
pub fn take_name(&mut self) -> String
pub fn number(&self) -> i32
pub fn clear_number(&mut self)
pub fn has_number(&self) -> bool
pub fn set_number(&mut self, v: i32)
pub fn label(&self) -> Label
pub fn clear_label(&mut self)
pub fn has_label(&self) -> bool
pub fn set_label(&mut self, v: Label)
pub fn type_(&self) -> Type
pub fn clear_type_(&mut self)
pub fn has_type(&self) -> bool
pub fn set_type(&mut self, v: Type)
pub fn type_name(&self) -> &str
pub fn clear_type_name(&mut self)
pub fn has_type_name(&self) -> bool
pub fn set_type_name(&mut self, v: String)
pub fn mut_type_name(&mut self) -> &mut String
pub fn take_type_name(&mut self) -> String
pub fn extendee(&self) -> &str
pub fn clear_extendee(&mut self)
pub fn has_extendee(&self) -> bool
pub fn set_extendee(&mut self, v: String)
pub fn mut_extendee(&mut self) -> &mut String
pub fn take_extendee(&mut self) -> String
pub fn default_value(&self) -> &str
pub fn clear_default_value(&mut self)
pub fn has_default_value(&self) -> bool
pub fn set_default_value(&mut self, v: String)
pub fn mut_default_value(&mut self) -> &mut String
pub fn take_default_value(&mut self) -> String
pub fn oneof_index(&self) -> i32
pub fn clear_oneof_index(&mut self)
pub fn has_oneof_index(&self) -> bool
pub fn set_oneof_index(&mut self, v: i32)
pub fn json_name(&self) -> &str
pub fn clear_json_name(&mut self)
pub fn has_json_name(&self) -> bool
pub fn set_json_name(&mut self, v: String)
pub fn mut_json_name(&mut self) -> &mut String
pub fn take_json_name(&mut self) -> String
pub fn proto3_optional(&self) -> bool
pub fn clear_proto3_optional(&mut self)
pub fn has_proto3_optional(&self) -> bool
pub fn set_proto3_optional(&mut self, v: bool)
Trait Implementations§
Source§impl Clone for FieldDescriptorProto
impl Clone for FieldDescriptorProto
Source§fn clone(&self) -> FieldDescriptorProto
fn clone(&self) -> FieldDescriptorProto
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for FieldDescriptorProto
impl Debug for FieldDescriptorProto
Source§impl<'a> Default for &'a FieldDescriptorProto
impl<'a> Default for &'a FieldDescriptorProto
Source§fn default() -> &'a FieldDescriptorProto
fn default() -> &'a FieldDescriptorProto
Source§impl Default for FieldDescriptorProto
impl Default for FieldDescriptorProto
Source§fn default() -> FieldDescriptorProto
fn default() -> FieldDescriptorProto
Source§impl Display for FieldDescriptorProto
impl Display for FieldDescriptorProto
Source§impl Message for FieldDescriptorProto
impl Message for FieldDescriptorProto
Source§const NAME: &'static str = "FieldDescriptorProto"
const NAME: &'static str = "FieldDescriptorProto"
.proto
file. Read moreSource§fn is_initialized(&self) -> bool
fn is_initialized(&self) -> bool
true
for protobuf 3.Source§fn merge_from(&mut self, is: &mut CodedInputStream<'_>) -> Result<()>
fn merge_from(&mut self, is: &mut CodedInputStream<'_>) -> Result<()>
Source§fn compute_size(&self) -> u64
fn compute_size(&self) -> u64
Source§fn write_to_with_cached_sizes(
&self,
os: &mut CodedOutputStream<'_>,
) -> Result<()>
fn write_to_with_cached_sizes( &self, os: &mut CodedOutputStream<'_>, ) -> Result<()>
Source§fn special_fields(&self) -> &SpecialFields
fn special_fields(&self) -> &SpecialFields
Source§fn mut_special_fields(&mut self) -> &mut SpecialFields
fn mut_special_fields(&mut self) -> &mut SpecialFields
Source§fn new() -> FieldDescriptorProto
fn new() -> FieldDescriptorProto
Source§fn default_instance() -> &'static FieldDescriptorProto
fn default_instance() -> &'static FieldDescriptorProto
Source§fn parse_from(is: &mut CodedInputStream<'_>) -> Result<Self>
fn parse_from(is: &mut CodedInputStream<'_>) -> Result<Self>
Source§fn cached_size(&self) -> u32
fn cached_size(&self) -> u32
compute_size
. Read moreSource§fn write_to(&self, os: &mut CodedOutputStream<'_>) -> Result<()>
fn write_to(&self, os: &mut CodedOutputStream<'_>) -> Result<()>
Source§fn write_length_delimited_to(
&self,
os: &mut CodedOutputStream<'_>,
) -> Result<()>
fn write_length_delimited_to( &self, os: &mut CodedOutputStream<'_>, ) -> Result<()>
Source§fn write_length_delimited_to_vec(&self, vec: &mut Vec<u8>) -> Result<()>
fn write_length_delimited_to_vec(&self, vec: &mut Vec<u8>) -> Result<()>
Source§fn merge_from_bytes(&mut self, bytes: &[u8]) -> Result<()>
fn merge_from_bytes(&mut self, bytes: &[u8]) -> Result<()>
Source§fn parse_from_reader(reader: &mut dyn Read) -> Result<Self>
fn parse_from_reader(reader: &mut dyn Read) -> Result<Self>
Source§fn parse_from_bytes(bytes: &[u8]) -> Result<Self>
fn parse_from_bytes(bytes: &[u8]) -> Result<Self>
Source§fn check_initialized(&self) -> Result<()>
fn check_initialized(&self) -> Result<()>
Source§fn write_length_delimited_to_writer(&self, w: &mut dyn Write) -> Result<()>
fn write_length_delimited_to_writer(&self, w: &mut dyn Write) -> Result<()>
Source§fn write_length_delimited_to_bytes(&self) -> Result<Vec<u8>>
fn write_length_delimited_to_bytes(&self) -> Result<Vec<u8>>
Source§fn unknown_fields(&self) -> &UnknownFields
fn unknown_fields(&self) -> &UnknownFields
Source§fn mut_unknown_fields(&mut self) -> &mut UnknownFields
fn mut_unknown_fields(&mut self) -> &mut UnknownFields
Source§impl MessageFull for FieldDescriptorProto
impl MessageFull for FieldDescriptorProto
Source§fn descriptor() -> MessageDescriptor
fn descriptor() -> MessageDescriptor
Source§fn reflect_eq(&self, other: &Self, mode: &ReflectEqMode) -> bool
fn reflect_eq(&self, other: &Self, mode: &ReflectEqMode) -> bool
Source§impl PartialEq for FieldDescriptorProto
impl PartialEq for FieldDescriptorProto
Source§impl ProtobufValue for FieldDescriptorProto
impl ProtobufValue for FieldDescriptorProto
Source§type RuntimeType = RuntimeTypeMessage<FieldDescriptorProto>
type RuntimeType = RuntimeTypeMessage<FieldDescriptorProto>
impl StructuralPartialEq for FieldDescriptorProto
Auto Trait Implementations§
impl !Freeze for FieldDescriptorProto
impl RefUnwindSafe for FieldDescriptorProto
impl Send for FieldDescriptorProto
impl Sync for FieldDescriptorProto
impl Unpin for FieldDescriptorProto
impl UnwindSafe for FieldDescriptorProto
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<M> MessageDyn for Mwhere
M: MessageFull,
impl<M> MessageDyn for Mwhere
M: MessageFull,
Source§fn descriptor_dyn(&self) -> MessageDescriptor
fn descriptor_dyn(&self) -> MessageDescriptor
Source§fn merge_from_dyn(&mut self, is: &mut CodedInputStream<'_>) -> Result<(), Error>
fn merge_from_dyn(&mut self, is: &mut CodedInputStream<'_>) -> Result<(), Error>
Source§fn write_to_with_cached_sizes_dyn(
&self,
os: &mut CodedOutputStream<'_>,
) -> Result<(), Error>
fn write_to_with_cached_sizes_dyn( &self, os: &mut CodedOutputStream<'_>, ) -> Result<(), Error>
Source§fn compute_size_dyn(&self) -> u64
fn compute_size_dyn(&self) -> u64
Source§fn is_initialized_dyn(&self) -> bool
fn is_initialized_dyn(&self) -> bool
true
for protobuf 3.