Struct prost_reflect::FileDescriptor
source · [−]pub struct FileDescriptor { /* private fields */ }Expand description
A wrapper around a FileDescriptorSet, which provides convenient APIs for the
protobuf message definitions.
This type is immutable once constructed, and uses reference counting internally so it is cheap to clone.
Implementations
sourceimpl FileDescriptor
impl FileDescriptor
sourcepub fn new(
file_descriptor_set: FileDescriptorSet
) -> Result<Self, DescriptorError>
pub fn new(
file_descriptor_set: FileDescriptorSet
) -> Result<Self, DescriptorError>
Create a FileDescriptor from a FileDescriptorSet.
A file descriptor set may be generated by running the protobuf compiler with the
--descriptor_set_out flag. If you are using prost-build,
then Config::file_descriptor_set_path
is a convenient way to generated it as part of your build.
This method may return an error if file_descriptor_set is invalid, for example
it contains references to types not in the set. If file_descriptor_set was created by
the protobuf compiler, these error cases should never occur since it performs its own
validation.
sourcepub fn decode<B>(bytes: B) -> Result<Self, DescriptorError> where
B: Buf,
pub fn decode<B>(bytes: B) -> Result<Self, DescriptorError> where
B: Buf,
Decodes a FileDescriptorSet from its protobuf byte representation and
creates a new FileDescriptor wrapping it.
sourcepub fn file_descriptor_set(&self) -> &FileDescriptorSet
pub fn file_descriptor_set(&self) -> &FileDescriptorSet
Gets a reference to the FileDescriptorSet wrapped by this FileDescriptor.
sourcepub fn services(&self) -> impl ExactSizeIterator<Item = ServiceDescriptor> + '_
pub fn services(&self) -> impl ExactSizeIterator<Item = ServiceDescriptor> + '_
Gets an iterator over the services defined in these protobuf files.
sourcepub fn all_messages(
&self
) -> impl ExactSizeIterator<Item = MessageDescriptor> + '_
pub fn all_messages(
&self
) -> impl ExactSizeIterator<Item = MessageDescriptor> + '_
Gets an iterator over all messages defined in these protobuf files.
The iterator includes nested messages defined in another message.
sourcepub fn all_enums(&self) -> impl ExactSizeIterator<Item = EnumDescriptor> + '_
pub fn all_enums(&self) -> impl ExactSizeIterator<Item = EnumDescriptor> + '_
Gets an iterator over all enums defined in these protobuf files.
The iterator includes nested enums defined in another message.
sourcepub fn all_extensions(
&self
) -> impl ExactSizeIterator<Item = ExtensionDescriptor> + '_
pub fn all_extensions(
&self
) -> impl ExactSizeIterator<Item = ExtensionDescriptor> + '_
Gets an iterator over all extension fields defined in these protobuf files.
The iterator includes nested extension fields defined in another message.
sourcepub fn get_message_by_name(&self, name: &str) -> Option<MessageDescriptor>
pub fn get_message_by_name(&self, name: &str) -> Option<MessageDescriptor>
Gets a MessageDescriptor by its fully qualified name, for example my.package.MessageName.
sourcepub fn get_enum_by_name(&self, name: &str) -> Option<EnumDescriptor>
pub fn get_enum_by_name(&self, name: &str) -> Option<EnumDescriptor>
Gets an EnumDescriptor by its fully qualified name, for example my.package.EnumName.
Trait Implementations
sourceimpl Clone for FileDescriptor
impl Clone for FileDescriptor
sourcefn clone(&self) -> FileDescriptor
fn clone(&self) -> FileDescriptor
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for FileDescriptor
impl Debug for FileDescriptor
sourceimpl PartialEq<FileDescriptor> for FileDescriptor
impl PartialEq<FileDescriptor> for FileDescriptor
impl Eq for FileDescriptor
Auto Trait Implementations
impl RefUnwindSafe for FileDescriptor
impl Send for FileDescriptor
impl Sync for FileDescriptor
impl Unpin for FileDescriptor
impl UnwindSafe for FileDescriptor
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more