pub struct FieldOptions {Show 14 fields
pub ctype: Option<CType>,
pub packed: Option<bool>,
pub jstype: Option<JSType>,
pub lazy: Option<bool>,
pub unverified_lazy: Option<bool>,
pub deprecated: Option<bool>,
pub weak: Option<bool>,
pub debug_redact: Option<bool>,
pub retention: Option<OptionRetention>,
pub targets: Vec<OptionTargetType>,
pub edition_defaults: Vec<EditionDefault>,
pub features: MessageField<FeatureSet>,
pub feature_support: MessageField<FeatureSupport>,
pub uninterpreted_option: Vec<UninterpretedOption>,
/* private fields */
}Fields§
§ctype: Option<CType>NOTE: ctype is deprecated. Use features.(pb.cpp).string_type instead.
The ctype option instructs the C++ code generator to use a different
representation of the field than it normally would. See the specific
options below. This option is only implemented to support use of
[ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of
type “bytes” in the open source release.
TODO: make ctype actually deprecated.
Field 1: ctype
packed: Option<bool>The packed option can be enabled for repeated primitive fields to enable
a more efficient representation on the wire. Rather than repeatedly
writing the tag and type for each element, the entire array is encoded as
a single length-delimited blob. In proto3, only explicit setting it to
false will avoid using packed encoding. This option is prohibited in
Editions, but the repeated_field_encoding feature can be used to control
the behavior.
Field 2: packed
jstype: Option<JSType>The jstype option determines the JavaScript type used for values of the field. The option is permitted only for 64 bit integral and fixed types (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING is represented as JavaScript string, which avoids loss of precision that can happen when a large value is converted to a floating point JavaScript. Specifying JS_NUMBER for the jstype causes the generated JavaScript code to use the JavaScript “number” type. The behavior of the default option JS_NORMAL is implementation dependent.
This option is an enum to permit additional types to be added, e.g. goog.math.Integer.
Field 6: jstype
lazy: Option<bool>Should this field be parsed lazily? Lazy applies only to message-type fields. It means that when the outer message is initially parsed, the inner message’s contents will not be parsed but instead stored in encoded form. The inner message will actually be parsed when it is first accessed.
This is only a hint. Implementations are free to choose whether to use eager or lazy parsing regardless of the value of this option. However, setting this option true suggests that the protocol author believes that using lazy parsing on this field is worth the additional bookkeeping overhead typically needed to implement it.
This option does not affect the public interface of any generated code; all method signatures remain the same. Furthermore, thread-safety of the interface is not affected by this option; const methods remain safe to call from multiple threads concurrently, while non-const methods continue to require exclusive access.
Note that lazy message fields are still eagerly verified to check ill-formed wireformat or missing required fields. Calling IsInitialized() on the outer message would fail if the inner message has missing required fields. Failed verification would result in parsing failure (except when uninitialized messages are acceptable).
Field 5: lazy
unverified_lazy: Option<bool>unverified_lazy does no correctness checks on the byte stream. This should only be used where lazy with verification is prohibitive for performance reasons.
Field 15: unverified_lazy
deprecated: Option<bool>Is this field deprecated? Depending on the target platform, this can emit Deprecated annotations for accessors, or it will be completely ignored; in the very least, this is a formalization for deprecating fields.
Field 3: deprecated
weak: Option<bool>DEPRECATED. DO NOT USE! For Google-internal migration only. Do not use.
Field 10: weak
debug_redact: Option<bool>Indicate that the field value should not be printed out when using debug formats, e.g. when the field contains sensitive credentials.
Field 16: debug_redact
retention: Option<OptionRetention>Field 17: retention
targets: Vec<OptionTargetType>Field 19: targets
edition_defaults: Vec<EditionDefault>Field 20: edition_defaults
features: MessageField<FeatureSet>Any features defined in the specific edition. WARNING: This field should only be used by protobuf plugins or special cases like the proto compiler. Other uses are discouraged and developers should rely on the protoreflect APIs for their client language.
Field 21: features
feature_support: MessageField<FeatureSupport>Field 22: feature_support
uninterpreted_option: Vec<UninterpretedOption>The parser stores options it doesn’t recognize here. See above.
Field 999: uninterpreted_option
Implementations§
Source§impl FieldOptions
impl FieldOptions
Source§impl FieldOptions
impl FieldOptions
Sourcepub fn with_ctype(self, value: impl Into<CType>) -> Self
pub fn with_ctype(self, value: impl Into<CType>) -> Self
Sets Self::ctype to Some(value), consuming and returning self.
Sourcepub fn with_packed(self, value: bool) -> Self
pub fn with_packed(self, value: bool) -> Self
Sets Self::packed to Some(value), consuming and returning self.
Sourcepub fn with_jstype(self, value: impl Into<JSType>) -> Self
pub fn with_jstype(self, value: impl Into<JSType>) -> Self
Sets Self::jstype to Some(value), consuming and returning self.
Sourcepub fn with_lazy(self, value: bool) -> Self
pub fn with_lazy(self, value: bool) -> Self
Sets Self::lazy to Some(value), consuming and returning self.
Sourcepub fn with_unverified_lazy(self, value: bool) -> Self
pub fn with_unverified_lazy(self, value: bool) -> Self
Sets Self::unverified_lazy to Some(value), consuming and returning self.
Sourcepub fn with_deprecated(self, value: bool) -> Self
pub fn with_deprecated(self, value: bool) -> Self
Sets Self::deprecated to Some(value), consuming and returning self.
Sourcepub fn with_weak(self, value: bool) -> Self
pub fn with_weak(self, value: bool) -> Self
Sets Self::weak to Some(value), consuming and returning self.
Sourcepub fn with_debug_redact(self, value: bool) -> Self
pub fn with_debug_redact(self, value: bool) -> Self
Sets Self::debug_redact to Some(value), consuming and returning self.
Sourcepub fn with_retention(self, value: impl Into<OptionRetention>) -> Self
pub fn with_retention(self, value: impl Into<OptionRetention>) -> Self
Sets Self::retention to Some(value), consuming and returning self.
Trait Implementations§
Source§impl Clone for FieldOptions
impl Clone for FieldOptions
Source§fn clone(&self) -> FieldOptions
fn clone(&self) -> FieldOptions
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 FieldOptions
impl Debug for FieldOptions
Source§impl Default for FieldOptions
impl Default for FieldOptions
Source§fn default() -> FieldOptions
fn default() -> FieldOptions
Source§impl DefaultInstance for FieldOptions
impl DefaultInstance for FieldOptions
Source§fn default_instance() -> &'static Self
fn default_instance() -> &'static Self
Source§impl ExtensionSet for FieldOptions
impl ExtensionSet for FieldOptions
Source§const PROTO_FQN: &'static str = "google.protobuf.FieldOptions"
const PROTO_FQN: &'static str = "google.protobuf.FieldOptions"
"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 FieldOptions
impl Message for FieldOptions
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 FieldOptions
impl MessageName for FieldOptions
Source§const PACKAGE: &'static str = "google.protobuf"
const PACKAGE: &'static str = "google.protobuf"
Source§const NAME: &'static str = "FieldOptions"
const NAME: &'static str = "FieldOptions"
. between nesting levels. Read moreSource§impl PartialEq for FieldOptions
impl PartialEq for FieldOptions
Source§fn eq(&self, other: &FieldOptions) -> bool
fn eq(&self, other: &FieldOptions) -> bool
self and other values to be equal, and is used by ==.