Struct protobuf::reflect::MessageDescriptor
source · [−]pub struct MessageDescriptor { /* private fields */ }
Expand description
Dynamic representation of message type.
Used for reflection.
Implementations
sourceimpl 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
sourceimpl Clone for MessageDescriptor
impl Clone for MessageDescriptor
sourcefn clone(&self) -> MessageDescriptor
fn clone(&self) -> MessageDescriptor
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more