Skip to main content

FileDescriptor

Struct FileDescriptor 

Source
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) -> FileDescriptor

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

Gets the dependencies of this file.

This corresponds to the FileDescriptorProto::dependency field.

Source

pub fn public_dependencies(&self) -> impl ExactSizeIterator

Gets the public dependencies of this file.

This corresponds to the FileDescriptorProto::public_dependency field.

Source

pub fn messages(&self) -> impl ExactSizeIterator

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

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

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

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 duplicate of the value. Read more
1.0.0 (const: unstable) · 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<(), Error>

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

impl Eq for FileDescriptor

Source§

impl PartialEq for FileDescriptor

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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.