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

A single source file containing protobuf messages and services.

Implementations§

source§

impl FileDescriptor

source

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.

source

pub fn parent_pool(&self) -> &DescriptorPool

Gets a reference to the DescriptorPool this file is included in.

source

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.

source

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.

source

pub fn index(&self) -> usize

Gets the index of this file within the parent DescriptorPool.

source

pub fn syntax(&self) -> Syntax

Gets the syntax of this protobuf file.

source

pub fn dependencies(&self) -> impl ExactSizeIterator<Item = FileDescriptor> + '_

Gets the dependencies of this file.

This corresponds to the FileDescriptorProto::dependency field.

source

pub fn public_dependencies( &self ) -> impl ExactSizeIterator<Item = FileDescriptor> + '_

Gets the public dependencies of this file.

This corresponds to the FileDescriptorProto::public_dependency field.

source

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.

source

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.

source

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.

source

pub fn services(&self) -> impl ExactSizeIterator<Item = ServiceDescriptor> + '_

Gets the services defined within this file.

source

pub fn file_descriptor_proto(&self) -> &FileDescriptorProto

Gets a reference to the raw FileDescriptorProto wrapped by this FileDescriptor.

source

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.

source

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.

source

pub fn options(&self) -> DynamicMessage

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

Trait Implementations§

source§

impl Clone for FileDescriptor

source§

fn clone(&self) -> FileDescriptor

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for FileDescriptor

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for FileDescriptor

source§

fn eq(&self, other: &FileDescriptor) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for FileDescriptor

source§

impl StructuralPartialEq for FileDescriptor

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.