pub struct Builder { /* private fields */ }
Expand description
Service generator builder.
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn build_client(self, enable: bool) -> Self
pub fn build_client(self, enable: bool) -> Self
Enable or disable client code generation.
Sourcepub fn build_server(self, enable: bool) -> Self
pub fn build_server(self, enable: bool) -> Self
Enable or disable server code generation.
Sourcepub fn build_scale_ext(self, enable: bool) -> Self
pub fn build_scale_ext(self, enable: bool) -> Self
Enable or disable scale codec extensions generation.
Sourcepub fn mod_prefix(self, prefix: impl Into<String>) -> Self
pub fn mod_prefix(self, prefix: impl Into<String>) -> Self
Module prefix of the generated code.
Sourcepub fn type_prefix(self, prefix: impl Into<String>) -> Self
pub fn type_prefix(self, prefix: impl Into<String>) -> Self
Type prefix of the scale codec anotation in the proto file.
Sourcepub fn out_dir(self, out_dir: impl AsRef<Path>) -> Self
pub fn out_dir(self, out_dir: impl AsRef<Path>) -> Self
Set the output directory to generate code to.
Defaults to the OUT_DIR
environment variable.
Sourcepub fn extern_path(
self,
proto_path: impl AsRef<str>,
rust_path: impl AsRef<str>,
) -> Self
pub fn extern_path( self, proto_path: impl AsRef<str>, rust_path: impl AsRef<str>, ) -> Self
Declare externally provided Protobuf package or type.
Passed directly to prost_build::Config.extern_path
.
Note that both the Protobuf path and the rust package paths should both be fully qualified.
i.e. Protobuf paths should start with “.” and rust paths should start with “::”
Sourcepub fn field_attribute<P: AsRef<str>, A: AsRef<str>>(
self,
path: P,
attribute: A,
) -> Self
pub fn field_attribute<P: AsRef<str>, A: AsRef<str>>( self, path: P, attribute: A, ) -> Self
Add additional attribute to matched messages, enums, and one-offs.
Passed directly to prost_build::Config.field_attribute
.
Sourcepub fn type_attribute<P: AsRef<str>, A: AsRef<str>>(
self,
path: P,
attribute: A,
) -> Self
pub fn type_attribute<P: AsRef<str>, A: AsRef<str>>( self, path: P, attribute: A, ) -> Self
Add additional attribute to matched messages, enums, and one-offs.
Passed directly to prost_build::Config.type_attribute
.
Sourcepub fn server_mod_attribute<P: AsRef<str>, A: AsRef<str>>(
self,
path: P,
attribute: A,
) -> Self
pub fn server_mod_attribute<P: AsRef<str>, A: AsRef<str>>( self, path: P, attribute: A, ) -> Self
Add additional attribute to matched server mod
s. Matches on the package name.
Sourcepub fn server_attribute<P: AsRef<str>, A: AsRef<str>>(
self,
path: P,
attribute: A,
) -> Self
pub fn server_attribute<P: AsRef<str>, A: AsRef<str>>( self, path: P, attribute: A, ) -> Self
Add additional attribute to matched service servers. Matches on the service name.
Sourcepub fn client_mod_attribute<P: AsRef<str>, A: AsRef<str>>(
self,
path: P,
attribute: A,
) -> Self
pub fn client_mod_attribute<P: AsRef<str>, A: AsRef<str>>( self, path: P, attribute: A, ) -> Self
Add additional attribute to matched client mod
s. Matches on the package name.
Sourcepub fn client_attribute<P: AsRef<str>, A: AsRef<str>>(
self,
path: P,
attribute: A,
) -> Self
pub fn client_attribute<P: AsRef<str>, A: AsRef<str>>( self, path: P, attribute: A, ) -> Self
Add additional attribute to matched service clients. Matches on the service name.
Sourcepub fn proto_path(self, proto_path: impl AsRef<str>) -> Self
pub fn proto_path(self, proto_path: impl AsRef<str>) -> Self
Set the path to where to search for the Request/Response proto structs
live relative to the module where you call include_proto!
.
This defaults to super
since we will generate code in a module.
Sourcepub fn protoc_arg<A: AsRef<str>>(self, arg: A) -> Self
pub fn protoc_arg<A: AsRef<str>>(self, arg: A) -> Self
Configure Prost protoc_args
build arguments.
Note: Enabling --experimental_allow_proto3_optional
requires protobuf >= 3.12.
Sourcepub fn disable_package_emission(self) -> Self
pub fn disable_package_emission(self) -> Self
Emits RPC endpoints with no attached package. Effectively ignores protofile package declaration from rpc context.
This effectively sets prost’s exported package to an empty string.
Sourcepub fn disable_service_name_emission(self) -> Self
pub fn disable_service_name_emission(self) -> Self
Disable emitting service name in rpc endpoints.
Sourcepub fn keep_service_name(self, name: impl Into<String>) -> Self
pub fn keep_service_name(self, name: impl Into<String>) -> Self
Keep the service name in rpc endpoints.
Sourcepub fn compile_well_known_types(self, compile_well_known_types: bool) -> Self
pub fn compile_well_known_types(self, compile_well_known_types: bool) -> Self
Enable or disable directing Prost to compile well-known protobuf types instead
of using the already-compiled versions available in the prost-types
crate.
This defaults to false
.
Sourcepub fn file_descriptor_set_path(self, path: impl Into<PathBuf>) -> Self
pub fn file_descriptor_set_path(self, path: impl Into<PathBuf>) -> Self
When set, the FileDescriptorSet
generated by protoc
is written to the provided
filesystem path.
This option can be used in conjunction with the include_bytes!
macro and the types in
the prost-types
crate for implementing reflection capabilities, among other things.
Sourcepub fn compile(
self,
protos: &[impl AsRef<Path>],
includes: &[impl AsRef<Path>],
) -> Result<()>
pub fn compile( self, protos: &[impl AsRef<Path>], includes: &[impl AsRef<Path>], ) -> Result<()>
Compile the .proto files and execute code generation.
Sourcepub fn compile_with_config(
self,
config: Config,
protos: &[impl AsRef<Path>],
includes: &[impl AsRef<Path>],
) -> Result<()>
pub fn compile_with_config( self, config: Config, protos: &[impl AsRef<Path>], includes: &[impl AsRef<Path>], ) -> Result<()>
Compile the .proto files and execute code generation using a
custom prost_build::Config
.
Sourcepub fn enable_serde_extension(self) -> Self
pub fn enable_serde_extension(self) -> Self
Enable serde serialization/deserialization for all generated types. This adds the necessary derives and attributes for serde compatibility.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more