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

A DescriptorPool is a collection of related descriptors. Typically it will be created from a FileDescriptorSet output by the protobuf compiler (see DescriptorPool::from_file_descriptor_set) but it may also be built up by adding files individually.

Methods like MessageDescriptor::extensions will be scoped to just the files contained within the parent DescriptorPool.

This type is uses reference counting internally so it is cheap to clone. Modifying an instance of a pool will not update any existing clones of the instance.

Implementations§

Creates a new, empty DescriptorPool.

For the common case of creating a DescriptorPool from a single FileDescriptorSet, see DescriptorPool::from_file_descriptor_set or DescriptorPool::decode.

Creates a DescriptorPool from a FileDescriptorSet.

This is equivalent to calling DescriptorPool::add_file_descriptor_set on an empty DescriptorPool instance. See that method’s documentation for details.

Decodes a FileDescriptorSet from its protobuf byte representation and creates a new DescriptorPool wrapping it.

Adds a new FileDescriptorSet to this DescriptorPool.

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 generate 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.

Adds a collection of file descriptors to this pool.

The file descriptors may be provided in any order, however all types referenced must be defined either in one of the files provided, or in a file previously added to the pool.

Duplicate file descriptors are ignored, however adding two different files with the same name will return an error.

Add a single file descriptor to the pool.

All types referenced by the file must be defined either in the file itself, or in a file previously added to the pool.

Decode and add a single file descriptor to the pool.

All types referenced by the file must be defined either in the file itself, or in a file previously added to the pool.

Unlike when using add_file_descriptor_proto(), any extension options defined in the file descriptor are preserved.

Decode and add a set of file descriptors to the pool.

The file descriptors may be provided in any order, however all types referenced must be defined either in one of the files provided, or in a file previously added to the pool.

Unlike when using add_file_descriptor_set(), any extension options defined in the file descriptors are preserved.

Gets an iterator over the file descriptors added to this pool.

Gets a file descriptor by its name, or None if no such file has been added.

Gets a iterator over the raw FileDescriptorProto instances wrapped by this DescriptorPool.

Encodes the files contained within this DescriptorPool to their byte representation.

The encoded message is equivalent to a FileDescriptorSet, however also includes any extension options that were defined.

Encodes the files contained within this DescriptorPool to a newly allocated buffer.

The encoded message is equivalent to a FileDescriptorSet, however also includes any extension options that were defined.

Gets an iterator over the services defined in these protobuf files.

Gets an iterator over all message types defined in these protobuf files.

The iterator includes nested messages defined in another message.

Gets an iterator over all enum types defined in these protobuf files.

The iterator includes nested enums defined in another message.

Gets an iterator over all extension fields defined in these protobuf files.

The iterator includes nested extension fields defined in another message.

Gets a MessageDescriptor by its fully qualified name, for example my.package.MessageName.

Gets an EnumDescriptor by its fully qualified name, for example my.package.EnumName.

Gets an ExtensionDescriptor by its fully qualified name, for example my.package.my_extension.

Gets an ServiceDescriptor by its fully qualified name, for example my.package.MyService.

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
Returns the “default value” for a type. Read more
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.