pub struct FieldDescriptorProto {
pub name: Option<String>,
pub number: Option<i32>,
pub label: Option<Label>,
pub type: Option<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>,
/* private fields */
}Expand description
Describes a field within a message.
Fields§
§name: Option<String>Field 1: name
number: Option<i32>Field 3: number
label: Option<Label>Field 4: label
type: Option<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.
Field 5: type
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).
Field 6: type_name
extendee: Option<String>For extensions, this is the name of the type being extended. It is resolved in the same manner as type_name.
Field 2: extendee
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.
Field 7: default_value
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.
Field 9: oneof_index
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.
Field 10: json_name
options: MessageField<FieldOptions>Field 8: options
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 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.
Field 17: proto3_optional
Implementations§
Source§impl FieldDescriptorProto
impl FieldDescriptorProto
Sourcepub fn with_name(self, value: impl Into<String>) -> Self
pub fn with_name(self, value: impl Into<String>) -> Self
Sets Self::name to Some(value), consuming and returning self.
Sourcepub fn with_number(self, value: i32) -> Self
pub fn with_number(self, value: i32) -> Self
Sets Self::number to Some(value), consuming and returning self.
Sourcepub fn with_label(self, value: impl Into<Label>) -> Self
pub fn with_label(self, value: impl Into<Label>) -> Self
Sets Self::label to Some(value), consuming and returning self.
Sourcepub fn with_type(self, value: impl Into<Type>) -> Self
pub fn with_type(self, value: impl Into<Type>) -> Self
Sets [Self::r#type] to Some(value), consuming and returning self.
Sourcepub fn with_type_name(self, value: impl Into<String>) -> Self
pub fn with_type_name(self, value: impl Into<String>) -> Self
Sets Self::type_name to Some(value), consuming and returning self.
Sourcepub fn with_extendee(self, value: impl Into<String>) -> Self
pub fn with_extendee(self, value: impl Into<String>) -> Self
Sets Self::extendee to Some(value), consuming and returning self.
Sourcepub fn with_default_value(self, value: impl Into<String>) -> Self
pub fn with_default_value(self, value: impl Into<String>) -> Self
Sets Self::default_value to Some(value), consuming and returning self.
Sourcepub fn with_oneof_index(self, value: i32) -> Self
pub fn with_oneof_index(self, value: i32) -> Self
Sets Self::oneof_index to Some(value), consuming and returning self.
Sourcepub fn with_json_name(self, value: impl Into<String>) -> Self
pub fn with_json_name(self, value: impl Into<String>) -> Self
Sets Self::json_name to Some(value), consuming and returning self.
Sourcepub fn with_proto3_optional(self, value: bool) -> Self
pub fn with_proto3_optional(self, value: bool) -> Self
Sets Self::proto3_optional to Some(value), consuming and returning self.
Trait Implementations§
Source§impl Clone for FieldDescriptorProto
impl Clone for FieldDescriptorProto
Source§fn clone(&self) -> FieldDescriptorProto
fn clone(&self) -> FieldDescriptorProto
1.0.0 (const: unstable) · 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 Default for FieldDescriptorProto
impl Default for FieldDescriptorProto
Source§fn default() -> FieldDescriptorProto
fn default() -> FieldDescriptorProto
Source§impl DefaultInstance for FieldDescriptorProto
impl DefaultInstance for FieldDescriptorProto
Source§fn default_instance() -> &'static Self
fn default_instance() -> &'static Self
Source§impl ExtensionSet for FieldDescriptorProto
impl ExtensionSet for FieldDescriptorProto
Source§const PROTO_FQN: &'static str = "google.protobuf.FieldDescriptorProto"
const PROTO_FQN: &'static str = "google.protobuf.FieldDescriptorProto"
"google.protobuf.FieldOptions". Read moreSource§fn unknown_fields(&self) -> &UnknownFields
fn unknown_fields(&self) -> &UnknownFields
Source§fn unknown_fields_mut(&mut self) -> &mut UnknownFields
fn unknown_fields_mut(&mut self) -> &mut UnknownFields
Source§fn extension<C>(&self, ext: &Extension<C>) -> <C as ExtensionCodec>::Outputwhere
C: ExtensionCodec,
fn extension<C>(&self, ext: &Extension<C>) -> <C as ExtensionCodec>::Outputwhere
C: ExtensionCodec,
Source§fn set_extension<C>(
&mut self,
ext: &Extension<C>,
value: <C as ExtensionCodec>::Value,
)where
C: ExtensionCodec,
fn set_extension<C>(
&mut self,
ext: &Extension<C>,
value: <C as ExtensionCodec>::Value,
)where
C: ExtensionCodec,
Source§fn has_extension<C>(&self, ext: &Extension<C>) -> boolwhere
C: ExtensionCodec,
fn has_extension<C>(&self, ext: &Extension<C>) -> boolwhere
C: ExtensionCodec,
true if any record at the extension’s field number is present. Read moreSource§fn clear_extension<C>(&mut self, ext: &Extension<C>)where
C: ExtensionCodec,
fn clear_extension<C>(&mut self, ext: &Extension<C>)where
C: ExtensionCodec,
Source§fn extension_or_default<C>(
&self,
ext: &Extension<C>,
) -> <C as ExtensionCodec>::Valuewhere
C: ExtensionCodec<Output = Option<<C as ExtensionCodec>::Value>>,
<C as ExtensionCodec>::Value: Default,
fn extension_or_default<C>(
&self,
ext: &Extension<C>,
) -> <C as ExtensionCodec>::Valuewhere
C: ExtensionCodec<Output = Option<<C as ExtensionCodec>::Value>>,
<C as ExtensionCodec>::Value: Default,
[default = ...]
value if absent, or the type’s Default if no proto default was declared. Read moreSource§impl Message for FieldDescriptorProto
impl Message for FieldDescriptorProto
Source§fn compute_size(&self, __cache: &mut SizeCache) -> u32
fn compute_size(&self, __cache: &mut SizeCache) -> u32
Returns the total encoded size in bytes.
The result is a u32; the protobuf specification requires all
messages to fit within 2 GiB (2,147,483,647 bytes), so a
compliant message will never overflow this type.
Source§fn write_to(&self, __cache: &mut SizeCache, buf: &mut impl BufMut)
fn write_to(&self, __cache: &mut SizeCache, buf: &mut impl BufMut)
cache (populated by a prior
compute_size call on the same cache). Read moreSource§fn merge_field(
&mut self,
tag: Tag,
buf: &mut impl Buf,
depth: u32,
) -> Result<(), DecodeError>
fn merge_field( &mut self, tag: Tag, buf: &mut impl Buf, depth: u32, ) -> Result<(), DecodeError>
buf. Read moreSource§fn encode(&self, buf: &mut impl BufMut)
fn encode(&self, buf: &mut impl BufMut)
Source§fn encode_with_cache(&self, cache: &mut SizeCache, buf: &mut impl BufMut)
fn encode_with_cache(&self, cache: &mut SizeCache, buf: &mut impl BufMut)
SizeCache, for
reuse across many encodes in a hot loop. Clears the cache first.Source§fn encoded_len(&self) -> u32
fn encoded_len(&self) -> u32
Source§fn encode_length_delimited(&self, buf: &mut impl BufMut)
fn encode_length_delimited(&self, buf: &mut impl BufMut)
Source§fn encode_to_bytes(&self) -> Bytes
fn encode_to_bytes(&self) -> Bytes
bytes::Bytes. Read moreSource§fn decode(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
fn decode(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
Source§fn decode_from_slice(data: &[u8]) -> Result<Self, DecodeError>where
Self: Sized,
fn decode_from_slice(data: &[u8]) -> Result<Self, DecodeError>where
Self: Sized,
Source§fn decode_length_delimited(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
fn decode_length_delimited(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
Source§fn merge_to_limit(
&mut self,
buf: &mut impl Buf,
depth: u32,
limit: usize,
) -> Result<(), DecodeError>
fn merge_to_limit( &mut self, buf: &mut impl Buf, depth: u32, limit: usize, ) -> Result<(), DecodeError>
Source§fn merge_group(
&mut self,
buf: &mut impl Buf,
depth: u32,
field_number: u32,
) -> Result<(), DecodeError>
fn merge_group( &mut self, buf: &mut impl Buf, depth: u32, field_number: u32, ) -> Result<(), DecodeError>
buf, reading fields until an
EndGroup tag with the given field_number is encountered. Read moreSource§fn merge(&mut self, buf: &mut impl Buf, depth: u32) -> Result<(), DecodeError>
fn merge(&mut self, buf: &mut impl Buf, depth: u32) -> Result<(), DecodeError>
Source§fn merge_from_slice(&mut self, data: &[u8]) -> Result<(), DecodeError>
fn merge_from_slice(&mut self, data: &[u8]) -> Result<(), DecodeError>
Source§fn merge_length_delimited(
&mut self,
buf: &mut impl Buf,
depth: u32,
) -> Result<(), DecodeError>
fn merge_length_delimited( &mut self, buf: &mut impl Buf, depth: u32, ) -> Result<(), DecodeError>
Source§impl MessageName for FieldDescriptorProto
impl MessageName for FieldDescriptorProto
Source§const PACKAGE: &'static str = "google.protobuf"
const PACKAGE: &'static str = "google.protobuf"
Source§const NAME: &'static str = "FieldDescriptorProto"
const NAME: &'static str = "FieldDescriptorProto"
. between nesting levels. Read moreSource§impl PartialEq for FieldDescriptorProto
impl PartialEq for FieldDescriptorProto
Source§fn eq(&self, other: &FieldDescriptorProto) -> bool
fn eq(&self, other: &FieldDescriptorProto) -> bool
self and other values to be equal, and is used by ==.