pub struct FileDescriptor { /* private fields */ }
Expand description
A single source file containing protobuf messages and services.
Implementations§
Source§impl FileDescriptor
impl FileDescriptor
Sourcepub fn new(descriptor_pool: DescriptorPool, index: usize) -> Self
pub fn new(descriptor_pool: DescriptorPool, index: usize) -> Self
Create a new FileDescriptor
referencing the file at index
within the given DescriptorPool
.
§Panics
Panics if index
is out-of-bounds.
Sourcepub fn parent_pool(&self) -> &DescriptorPool
pub fn parent_pool(&self) -> &DescriptorPool
Gets a reference to the DescriptorPool
this file is included in.
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Gets the unique name of this file relative to the root of the source tree,
e.g. path/to/my_package.proto
.
Sourcepub fn package_name(&self) -> &str
pub fn package_name(&self) -> &str
Gets the name of the package specifier for a file, e.g. my.package
.
If no package name is set, an empty string is returned.
Sourcepub fn index(&self) -> usize
pub fn index(&self) -> usize
Gets the index of this file within the parent DescriptorPool
.
Sourcepub fn dependencies(&self) -> impl ExactSizeIterator<Item = FileDescriptor> + '_
pub fn dependencies(&self) -> impl ExactSizeIterator<Item = FileDescriptor> + '_
Gets the dependencies of this file.
This corresponds to the FileDescriptorProto::dependency
field.
Sourcepub fn public_dependencies(
&self,
) -> impl ExactSizeIterator<Item = FileDescriptor> + '_
pub fn public_dependencies( &self, ) -> impl ExactSizeIterator<Item = FileDescriptor> + '_
Gets the public dependencies of this file.
This corresponds to the FileDescriptorProto::public_dependency
field.
Sourcepub fn messages(&self) -> impl ExactSizeIterator<Item = MessageDescriptor> + '_
pub fn messages(&self) -> impl ExactSizeIterator<Item = MessageDescriptor> + '_
Gets the top-level message types defined within this file.
This does not include nested messages defined within another message.
Sourcepub fn enums(&self) -> impl ExactSizeIterator<Item = EnumDescriptor> + '_
pub fn enums(&self) -> impl ExactSizeIterator<Item = EnumDescriptor> + '_
Gets the top-level enum types defined within this file.
This does not include nested enums defined within another message.
Sourcepub fn extensions(
&self,
) -> impl ExactSizeIterator<Item = ExtensionDescriptor> + '_
pub fn extensions( &self, ) -> impl ExactSizeIterator<Item = ExtensionDescriptor> + '_
Gets the top-level extension fields defined within this file.
This does not include nested extensions defined within another message.
Sourcepub fn services(&self) -> impl ExactSizeIterator<Item = ServiceDescriptor> + '_
pub fn services(&self) -> impl ExactSizeIterator<Item = ServiceDescriptor> + '_
Gets the services defined within this file.
Sourcepub fn file_descriptor_proto(&self) -> &FileDescriptorProto
pub fn file_descriptor_proto(&self) -> &FileDescriptorProto
Gets a reference to the raw FileDescriptorProto
wrapped by this FileDescriptor
.
Sourcepub fn encode<B>(&self, buf: B) -> Result<(), EncodeError>where
B: BufMut,
pub fn encode<B>(&self, buf: B) -> Result<(), EncodeError>where
B: BufMut,
Encodes this file descriptor to its byte representation.
The encoded message is equivalent to a FileDescriptorProto
, however also includes
any extension options that were defined.
Sourcepub fn encode_to_vec(&self) -> Vec<u8> ⓘ
pub fn encode_to_vec(&self) -> Vec<u8> ⓘ
Encodes this file descriptor to a newly allocated buffer.
The encoded message is equivalent to a FileDescriptorProto
, however also includes
any extension options that were defined.
Sourcepub fn options(&self) -> DynamicMessage
pub fn options(&self) -> DynamicMessage
Decodes the options defined for this FileDescriptor
, including any extension options.
Trait Implementations§
Source§impl Clone for FileDescriptor
impl Clone for FileDescriptor
Source§fn clone(&self) -> FileDescriptor
fn clone(&self) -> FileDescriptor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more