pub struct MessageDescriptor { /* private fields */ }
Expand description

A protobuf message definition.

Implementations§

Gets a reference to the DescriptorPool this message is defined in.

Gets the FileDescriptor this message is defined in.

Gets the parent message type if this message type is nested inside a another message, or None otherwise

Gets the short name of the message type, e.g. MyMessage.

Gets the full name of the message type, e.g. my.package.MyMessage.

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.

Gets the path where this message is defined within the FileDescriptorProto, e.g. [4, 0].

See path for more details on the structure of the path.

Gets a reference to the FileDescriptorProto in which this message is defined.

Gets a reference to the raw DescriptorProto wrapped by this MessageDescriptor.

Decodes the options defined for this MessageDescriptor, including any extension options.

Gets an iterator yielding a FieldDescriptor for each field defined in this message.

Gets an iterator yielding a OneofDescriptor for each oneof field defined in this message.

Gets the nested message types defined within this message.

Gets the nested enum types defined within this message.

Gets the nested extension fields defined within this message.

Note this only returns extensions defined nested within this message. See MessageDescriptor::extensions to get fields defined anywhere that extend this message.

Gets an iterator over all extensions to this message defined in the parent DescriptorPool.

Note this iterates over extension fields defined anywhere which extend this message. See MessageDescriptor::child_extensions to just get extensions defined nested within this message.

Gets a FieldDescriptor with the given number, or None if no such field exists.

Gets a FieldDescriptor with the given name, or None if no such field exists.

Gets a FieldDescriptor with the given JSON name, or None if no such field exists.

source

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.

source

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.

source

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.

Gets an iterator over reserved field number ranges in this message.

Gets an iterator over reserved field names in this message.

Gets an iterator over extension field number ranges in this message.

Gets an extension to this message by its number, or None if no such extension exists.

Gets an extension to this message by its full name (e.g. my.package.my_extension), or None if no such extension exists.

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§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Deserialize a DynamicMessage from deserializer using the canonical JSON encoding.

Examples
use serde::de::DeserializeSeed;

let json = r#"{ "foo": 150 }"#;
let mut deserializer = serde_json::de::Deserializer::from_str(json);
let dynamic_message = message_descriptor.deserialize(&mut deserializer).unwrap();
deserializer.end().unwrap();

assert_eq!(dynamic_message.get_field_by_name("foo").unwrap().as_ref(), &Value::I32(150));
The type produced by using this seed.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.