pub struct MessageDescriptor { /* private fields */ }
Expand description
Dynamic representation of message type.
Used for reflection.
Implementations§
Source§impl MessageDescriptor
impl MessageDescriptor
Sourcepub fn proto(&self) -> &DescriptorProto
pub fn proto(&self) -> &DescriptorProto
Get underlying DescriptorProto
object.
Sourcepub fn for_type<M: MessageFull>() -> MessageDescriptor
pub fn for_type<M: MessageFull>() -> MessageDescriptor
Get a message descriptor for given message type
Sourcepub fn nested_messages(&self) -> impl Iterator<Item = MessageDescriptor> + '_
pub fn nested_messages(&self) -> impl Iterator<Item = MessageDescriptor> + '_
Messages declared in this messages.
Sourcepub fn nested_enums(&self) -> impl Iterator<Item = EnumDescriptor> + '_
pub fn nested_enums(&self) -> impl Iterator<Item = EnumDescriptor> + '_
Get enums declared in this message.
Sourcepub fn enclosing_message(&self) -> Option<MessageDescriptor>
pub fn enclosing_message(&self) -> Option<MessageDescriptor>
Get a message containing this message, or None
if this message is declared at file level.
Sourcepub fn file_descriptor(&self) -> &FileDescriptor
pub fn file_descriptor(&self) -> &FileDescriptor
FileDescriptor
containing this message.
Sourcepub fn file_descriptor_proto(&self) -> &FileDescriptorProto
pub fn file_descriptor_proto(&self) -> &FileDescriptorProto
FileDescriptorProto
containg this message type
Sourcepub fn is_map_entry(&self) -> bool
pub fn is_map_entry(&self) -> bool
This message descriptor is a map entry.
Sourcepub fn new_instance(&self) -> Box<dyn MessageDyn>
pub fn new_instance(&self) -> Box<dyn MessageDyn>
Sourcepub fn default_instance(&self) -> Option<&'static dyn MessageDyn>
pub fn default_instance(&self) -> Option<&'static dyn MessageDyn>
Shared immutable empty message.
Returns None
for dynamic message.
§Panics
If this message is a map entry message.
Sourcepub fn eq(&self, a: &dyn MessageDyn, b: &dyn MessageDyn) -> bool
pub fn eq(&self, a: &dyn MessageDyn, b: &dyn MessageDyn) -> bool
Sourcepub fn name_to_package(&self) -> &str
pub fn name_to_package(&self) -> &str
Name relative to the package where the message is declared.
Sourcepub fn all_oneofs<'a>(&'a self) -> impl Iterator<Item = OneofDescriptor> + 'a
pub fn all_oneofs<'a>(&'a self) -> impl Iterator<Item = OneofDescriptor> + 'a
Nested oneofs including synthetic.
Sourcepub fn oneofs<'a>(&'a self) -> impl Iterator<Item = OneofDescriptor> + 'a
pub fn oneofs<'a>(&'a self) -> impl Iterator<Item = OneofDescriptor> + 'a
Non-synthetic oneofs.
Sourcepub fn oneof_by_name(&self, name: &str) -> Option<OneofDescriptor>
pub fn oneof_by_name(&self, name: &str) -> Option<OneofDescriptor>
Get message oneof by name (not implemented).
Sourcepub fn fields<'a>(&'a self) -> impl Iterator<Item = FieldDescriptor> + 'a
pub fn fields<'a>(&'a self) -> impl Iterator<Item = FieldDescriptor> + 'a
Message field descriptors.
Sourcepub fn extensions(&self) -> impl Iterator<Item = FieldDescriptor> + '_
pub fn extensions(&self) -> impl Iterator<Item = FieldDescriptor> + '_
Extension fields.
Sourcepub fn field_by_name(&self, name: &str) -> Option<FieldDescriptor>
pub fn field_by_name(&self, name: &str) -> Option<FieldDescriptor>
Find message field by protobuf field name
Note: protobuf field name might be different for Rust field name.
Sourcepub fn field_by_name_or_json_name<'a>(
&'a self,
name: &str,
) -> Option<FieldDescriptor>
pub fn field_by_name_or_json_name<'a>( &'a self, name: &str, ) -> Option<FieldDescriptor>
Find message field by field name or field JSON name
Sourcepub fn field_by_number(&self, number: u32) -> Option<FieldDescriptor>
pub fn field_by_number(&self, number: u32) -> Option<FieldDescriptor>
Find message field by field name
Sourcepub fn parse_from(
&self,
is: &mut CodedInputStream<'_>,
) -> Result<Box<dyn MessageDyn>>
pub fn parse_from( &self, is: &mut CodedInputStream<'_>, ) -> Result<Box<dyn MessageDyn>>
Parse message from stream.
Sourcepub fn parse_from_reader(
&self,
reader: &mut dyn Read,
) -> Result<Box<dyn MessageDyn>>
pub fn parse_from_reader( &self, reader: &mut dyn Read, ) -> Result<Box<dyn MessageDyn>>
Parse message from reader. Parse stops on EOF or when error encountered.
Sourcepub fn parse_from_bytes(&self, bytes: &[u8]) -> Result<Box<dyn MessageDyn>>
pub fn parse_from_bytes(&self, bytes: &[u8]) -> Result<Box<dyn MessageDyn>>
Parse message from byte array.
Trait Implementations§
Source§impl Clone for MessageDescriptor
impl Clone for MessageDescriptor
Source§fn clone(&self) -> MessageDescriptor
fn clone(&self) -> MessageDescriptor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more