pub struct FieldDescriptor { /* private fields */ }
Expand description
Field descriptor.
Can be used for runtime reflection.
Implementations§
Source§impl FieldDescriptor
impl FieldDescriptor
Sourcepub fn proto(&self) -> &FieldDescriptorProto
pub fn proto(&self) -> &FieldDescriptorProto
Get .proto
description of field
Sourcepub fn full_name(&self) -> String
pub fn full_name(&self) -> String
Fully qualified name of the field: fully qualified name of the declaring type followed by the field name.
Declaring type is a message (for regular field or extensions) or a package (for top-level extensions).
Sourcepub fn containing_oneof_including_synthetic(&self) -> Option<OneofDescriptor>
pub fn containing_oneof_including_synthetic(&self) -> Option<OneofDescriptor>
Oneof descriptor containing this field. Do not skip synthetic oneofs.
Sourcepub fn containing_oneof(&self) -> Option<OneofDescriptor>
pub fn containing_oneof(&self) -> Option<OneofDescriptor>
Oneof containing this field.
Return None
if this field is not part of oneof or if it is synthetic oneof.
Sourcepub fn containing_message(&self) -> MessageDescriptor
pub fn containing_message(&self) -> MessageDescriptor
Message which contains this field.
For extension fields, this is the message being extended.
Sourcepub fn is_singular(&self) -> bool
pub fn is_singular(&self) -> bool
If this field is optional or required.
Sourcepub fn is_required(&self) -> bool
pub fn is_required(&self) -> bool
Is this field required.
Sourcepub fn is_repeated_or_map(&self) -> bool
pub fn is_repeated_or_map(&self) -> bool
If this field repeated or map?
Sourcepub fn is_repeated(&self) -> bool
pub fn is_repeated(&self) -> bool
Is this field repeated, but not map field?
Sourcepub fn has_field(&self, m: &dyn MessageDyn) -> bool
pub fn has_field(&self, m: &dyn MessageDyn) -> bool
Check if field is set in given message.
For repeated field or map field return true
if
collection is not empty.
§Panics
If this field belongs to a different message type.
Sourcepub fn get_message<'a>(&self, m: &'a dyn MessageDyn) -> MessageRef<'a>
pub fn get_message<'a>(&self, m: &'a dyn MessageDyn) -> MessageRef<'a>
Get message field or default instance if field is unset.
§Panics
If this field belongs to a different message type or field type is not message.
Sourcepub fn mut_message<'a>(
&self,
m: &'a mut dyn MessageDyn,
) -> &'a mut dyn MessageDyn
pub fn mut_message<'a>( &self, m: &'a mut dyn MessageDyn, ) -> &'a mut dyn MessageDyn
Get a mutable reference to a message field. Initialize field with default message if unset.
§Panics
If this field belongs to a different message type or field type is not singular message.
Sourcepub fn singular_default_value(&self) -> ReflectValueRef<'_>
pub fn singular_default_value(&self) -> ReflectValueRef<'_>
Sourcepub fn get_singular_field_or_default<'a>(
&self,
m: &'a dyn MessageDyn,
) -> ReflectValueRef<'a>
pub fn get_singular_field_or_default<'a>( &self, m: &'a dyn MessageDyn, ) -> ReflectValueRef<'a>
Get singular field value.
Return field default value if field is unset.
§Panics
If this field belongs to a different message type or fields is not singular.
Sourcepub fn singular_runtime_type(&self) -> RuntimeType
pub fn singular_runtime_type(&self) -> RuntimeType
Runtime representation of singular field.
§Panics
If this field belongs to a different message type or field is not singular.
Sourcepub fn set_singular_field(&self, m: &mut dyn MessageDyn, value: ReflectValueBox)
pub fn set_singular_field(&self, m: &mut dyn MessageDyn, value: ReflectValueBox)
Set singular field.
§Panics
If this field belongs to a different message type or field is not singular or value is of different type.
Sourcepub fn clear_field(&self, m: &mut dyn MessageDyn)
pub fn clear_field(&self, m: &mut dyn MessageDyn)
Clear a field.
Sourcepub fn runtime_field_type(&self) -> RuntimeFieldType
pub fn runtime_field_type(&self) -> RuntimeFieldType
Dynamic representation of field type.
Sourcepub fn get_reflect<'a>(&self, m: &'a dyn MessageDyn) -> ReflectFieldRef<'a>
pub fn get_reflect<'a>(&self, m: &'a dyn MessageDyn) -> ReflectFieldRef<'a>
Sourcepub fn get_singular<'a>(
&self,
m: &'a dyn MessageDyn,
) -> Option<ReflectValueRef<'a>>
pub fn get_singular<'a>( &self, m: &'a dyn MessageDyn, ) -> Option<ReflectValueRef<'a>>
Get singular field value.
Return None
if field is unset.
§Panics
If this field belongs to a different message type or fields is not singular.
Sourcepub fn get_repeated<'a>(&self, m: &'a dyn MessageDyn) -> ReflectRepeatedRef<'a>
pub fn get_repeated<'a>(&self, m: &'a dyn MessageDyn) -> ReflectRepeatedRef<'a>
Get repeated field.
§Panics
If this field belongs to a different message type or field is not repeated.
Sourcepub fn mut_repeated<'a>(
&self,
m: &'a mut dyn MessageDyn,
) -> ReflectRepeatedMut<'a>
pub fn mut_repeated<'a>( &self, m: &'a mut dyn MessageDyn, ) -> ReflectRepeatedMut<'a>
Get a mutable reference to repeated
field.
§Panics
If this field belongs to a different message type or field is not repeated
.
Sourcepub fn get_map<'a>(&self, m: &'a dyn MessageDyn) -> ReflectMapRef<'a>
pub fn get_map<'a>(&self, m: &'a dyn MessageDyn) -> ReflectMapRef<'a>
Sourcepub fn mut_map<'a>(&self, m: &'a mut dyn MessageDyn) -> ReflectMapMut<'a>
pub fn mut_map<'a>(&self, m: &'a mut dyn MessageDyn) -> ReflectMapMut<'a>
Get a mutable reference to map
field.
§Panics
If this field belongs to a different message type or field is not map
.
Trait Implementations§
Source§impl Clone for FieldDescriptor
impl Clone for FieldDescriptor
Source§fn clone(&self) -> FieldDescriptor
fn clone(&self) -> FieldDescriptor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more