Struct protobuf::reflect::FieldDescriptor
source · 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) -> &'static FieldDescriptorProto
pub fn proto(&self) -> &'static FieldDescriptorProto
Get .proto
description of field
sourcepub fn is_repeated(&self) -> bool
pub fn is_repeated(&self) -> bool
If this field repeated?
sourcepub fn has_field(&self, m: &dyn Message) -> bool
pub fn has_field(&self, m: &dyn Message) -> 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 len_field(&self, m: &dyn Message) -> usize
pub fn len_field(&self, m: &dyn Message) -> usize
Return length of repeated field.
For singular field return 1
if field is set and 0
otherwise.
Panics
If this field belongs to a different message type.
sourcepub fn get_message<'a>(&self, m: &'a dyn Message) -> &'a dyn Message
pub fn get_message<'a>(&self, m: &'a dyn Message) -> &'a dyn Message
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 get_enum(&self, m: &dyn Message) -> &'static EnumValueDescriptor
pub fn get_enum(&self, m: &dyn Message) -> &'static EnumValueDescriptor
Get enum
field.
Panics
If this field belongs to a different message type
or field type is not singular enum
.
sourcepub fn get_str<'a>(&self, m: &'a dyn Message) -> &'a str
pub fn get_str<'a>(&self, m: &'a dyn Message) -> &'a str
Get string
field.
Panics
If this field belongs to a different message type
or field type is not singular string
.
sourcepub fn get_bytes<'a>(&self, m: &'a dyn Message) -> &'a [u8] ⓘ
pub fn get_bytes<'a>(&self, m: &'a dyn Message) -> &'a [u8] ⓘ
Get bytes
field.
Panics
If this field belongs to a different message type
or field type is not singular bytes
.
sourcepub fn get_u32(&self, m: &dyn Message) -> u32
pub fn get_u32(&self, m: &dyn Message) -> u32
Get u32
field.
Panics
If this field belongs to a different message type
or field type is not singular u32
.
sourcepub fn get_u64(&self, m: &dyn Message) -> u64
pub fn get_u64(&self, m: &dyn Message) -> u64
Get u64
field.
Panics
If this field belongs to a different message type
or field type is not singular u64
.
sourcepub fn get_i32(&self, m: &dyn Message) -> i32
pub fn get_i32(&self, m: &dyn Message) -> i32
Get i32
field.
Panics
If this field belongs to a different message type
or field type is not singular i32
.
sourcepub fn get_i64(&self, m: &dyn Message) -> i64
pub fn get_i64(&self, m: &dyn Message) -> i64
Get i64
field.
Panics
If this field belongs to a different message type
or field type is not singular i64
.
sourcepub fn get_bool(&self, m: &dyn Message) -> bool
pub fn get_bool(&self, m: &dyn Message) -> bool
Get bool
field.
Panics
If this field belongs to a different message type or
field type is not singular bool
.
sourcepub fn get_f32(&self, m: &dyn Message) -> f32
pub fn get_f32(&self, m: &dyn Message) -> f32
Get float
field.
Panics
If this field belongs to a different message type or
field type is not singular float
.
sourcepub fn get_f64(&self, m: &dyn Message) -> f64
pub fn get_f64(&self, m: &dyn Message) -> f64
Get double
field.
Panics
If this field belongs to a different message type
or field type is not singular double
.