Struct prost_reflect::MessageDescriptor
source · [−]pub struct MessageDescriptor { /* private fields */ }Expand description
A protobuf message definition.
Implementations
sourceimpl MessageDescriptor
impl MessageDescriptor
sourcepub fn parent_pool(&self) -> &DescriptorPool
pub fn parent_pool(&self) -> &DescriptorPool
Gets a reference to the DescriptorPool this message is defined in.
sourcepub fn parent_message(&self) -> Option<MessageDescriptor>
pub fn parent_message(&self) -> Option<MessageDescriptor>
Gets the parent message type if this message type is nested inside a another message, or None otherwise
sourcepub fn full_name(&self) -> &str
pub fn full_name(&self) -> &str
Gets the full name of the message type, e.g. my.package.MyMessage.
sourcepub fn package_name(&self) -> &str
pub fn package_name(&self) -> &str
Gets the name of the package this message type is defined in, e.g. my.package.
If no package name is set, an empty string is returned.
sourcepub fn parent_file_descriptor_proto(&self) -> &FileDescriptorProto
pub fn parent_file_descriptor_proto(&self) -> &FileDescriptorProto
Gets a reference to the FileDescriptorProto in which this message is defined.
sourcepub fn descriptor_proto(&self) -> &DescriptorProto
pub fn descriptor_proto(&self) -> &DescriptorProto
Gets a reference to the raw DescriptorProto wrapped by this MessageDescriptor.
sourcepub fn fields(&self) -> impl ExactSizeIterator<Item = FieldDescriptor> + '_
pub fn fields(&self) -> impl ExactSizeIterator<Item = FieldDescriptor> + '_
Gets an iterator yielding a FieldDescriptor for each field defined in this message.
sourcepub fn oneofs(&self) -> impl ExactSizeIterator<Item = OneofDescriptor> + '_
pub fn oneofs(&self) -> impl ExactSizeIterator<Item = OneofDescriptor> + '_
Gets an iterator yielding a OneofDescriptor for each oneof field defined in this message.
sourcepub fn get_field(&self, number: u32) -> Option<FieldDescriptor>
pub fn get_field(&self, number: u32) -> Option<FieldDescriptor>
Gets a FieldDescriptor with the given number, or None if no such field exists.
sourcepub fn get_field_by_name(&self, name: &str) -> Option<FieldDescriptor>
pub fn get_field_by_name(&self, name: &str) -> Option<FieldDescriptor>
Gets a FieldDescriptor with the given name, or None if no such field exists.
sourcepub fn get_field_by_json_name(&self, json_name: &str) -> Option<FieldDescriptor>
pub fn get_field_by_json_name(&self, json_name: &str) -> Option<FieldDescriptor>
Gets a FieldDescriptor with the given JSON name, or None if no such field exists.
sourcepub fn is_map_entry(&self) -> bool
pub fn is_map_entry(&self) -> bool
Returns true if this is an auto-generated message type to
represent the entry type for a map field.
If this method returns true, fields is guaranteed to
yield the following two fields:
- A “key” field with a field number of 1
- A “value” field with a field number of 2
See map_entry_key_field and
map_entry_value_field for more a convenient way
to get these fields.
sourcepub fn map_entry_key_field(&self) -> FieldDescriptor
pub fn map_entry_key_field(&self) -> FieldDescriptor
If this is a map entry, returns a FieldDescriptor for the key.
Panics
This method may panic if is_map_entry returns false.
sourcepub fn map_entry_value_field(&self) -> FieldDescriptor
pub fn map_entry_value_field(&self) -> FieldDescriptor
If this is a map entry, returns a FieldDescriptor for the value.
Panics
This method may panic if is_map_entry returns false.
sourcepub fn reserved_ranges(&self) -> impl ExactSizeIterator<Item = Range<u32>> + '_
pub fn reserved_ranges(&self) -> impl ExactSizeIterator<Item = Range<u32>> + '_
Gets an iterator over reserved field number ranges in this message.
sourcepub fn reserved_names(&self) -> impl ExactSizeIterator<Item = &str> + '_
pub fn reserved_names(&self) -> impl ExactSizeIterator<Item = &str> + '_
Gets an iterator over reserved field names in this message.
sourcepub fn extension_ranges(&self) -> impl ExactSizeIterator<Item = Range<u32>> + '_
pub fn extension_ranges(&self) -> impl ExactSizeIterator<Item = Range<u32>> + '_
Gets an iterator over extension field number ranges in this message.
sourcepub fn extensions(
&self
) -> impl ExactSizeIterator<Item = ExtensionDescriptor> + '_
pub fn extensions(
&self
) -> impl ExactSizeIterator<Item = ExtensionDescriptor> + '_
Gets an iterator over extensions to this message.
Note this iterates over extension fields defined in any file which extend this message, rather than extensions defined nested within this message.
sourcepub fn get_extension(&self, number: u32) -> Option<ExtensionDescriptor>
pub fn get_extension(&self, number: u32) -> Option<ExtensionDescriptor>
Gets an extension to this message by its number, or None if no such extension exists.
sourcepub fn get_extension_by_json_name(
&self,
name: &str
) -> Option<ExtensionDescriptor>
pub fn get_extension_by_json_name(
&self,
name: &str
) -> Option<ExtensionDescriptor>
Gets an extension to this message by its JSON name (e.g. [my.package.my_extension]), or None if no such extension exists.
Trait Implementations
sourceimpl Clone for MessageDescriptor
impl Clone for MessageDescriptor
sourcefn clone(&self) -> MessageDescriptor
fn clone(&self) -> MessageDescriptor
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for MessageDescriptor
impl Debug for MessageDescriptor
sourceimpl<'de> DeserializeSeed<'de> for MessageDescriptor
Available on crate feature serde only.
impl<'de> DeserializeSeed<'de> for MessageDescriptor
serde only.sourcefn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error> where
D: Deserializer<'de>,
Deserialize a DynamicMessage from deserializer using the canonical JSON encoding.
type Value = DynamicMessage
type Value = DynamicMessage
The type produced by using this seed.
sourceimpl PartialEq<MessageDescriptor> for MessageDescriptor
impl PartialEq<MessageDescriptor> for MessageDescriptor
sourcefn eq(&self, other: &MessageDescriptor) -> bool
fn eq(&self, other: &MessageDescriptor) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &MessageDescriptor) -> bool
fn ne(&self, other: &MessageDescriptor) -> bool
This method tests for !=.
impl Eq for MessageDescriptor
impl StructuralEq for MessageDescriptor
impl StructuralPartialEq for MessageDescriptor
Auto Trait Implementations
impl RefUnwindSafe for MessageDescriptor
impl Send for MessageDescriptor
impl Sync for MessageDescriptor
impl Unpin for MessageDescriptor
impl UnwindSafe for MessageDescriptor
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more