pub struct CodeGenBuilder { /* private fields */ }Expand description
Builder for the generic code generation of server and clients.
Implementations§
Source§impl CodeGenBuilder
impl CodeGenBuilder
Sourcepub fn emit_package(&mut self, enable: bool) -> &mut Self
pub fn emit_package(&mut self, enable: bool) -> &mut Self
Enable code generation to emit the package name.
Sourcepub fn attributes(&mut self, attributes: Attributes) -> &mut Self
pub fn attributes(&mut self, attributes: Attributes) -> &mut Self
Attributes that will be added to mod and struct items.
Reference Attributes for more information.
Sourcepub fn build_transport(&mut self, build_transport: bool) -> &mut Self
pub fn build_transport(&mut self, build_transport: bool) -> &mut Self
Enable transport code to be generated, this requires tonic’s transport
feature.
This allows codegen level control of generating the transport code and is a work around when other crates in a workspace enable this feature.
Sourcepub fn compile_well_known_types(&mut self, enable: bool) -> &mut Self
pub fn compile_well_known_types(&mut self, enable: bool) -> &mut Self
Enable compiling well known types, this will force codegen to not
use the well known types from prost-types.
Sourcepub fn disable_comments(
&mut self,
disable_comments: HashSet<String>,
) -> &mut Self
pub fn disable_comments( &mut self, disable_comments: HashSet<String>, ) -> &mut Self
Disable comments based on a proto path.
Sourcepub fn use_arc_self(&mut self, enable: bool) -> &mut Self
pub fn use_arc_self(&mut self, enable: bool) -> &mut Self
Emit Arc<Self> instead of &self in service trait.
Sourcepub fn generate_default_stubs(
&mut self,
generate_default_stubs: bool,
) -> &mut Self
pub fn generate_default_stubs( &mut self, generate_default_stubs: bool, ) -> &mut Self
Enable or disable returning automatic unimplemented gRPC error code for generated traits.
Sourcepub fn generate_client(
&self,
service: &impl Service,
proto_path: &str,
) -> TokenStream
pub fn generate_client( &self, service: &impl Service, proto_path: &str, ) -> TokenStream
Generate client code based on Service.
This takes some Service and will generate a TokenStream that contains
a public module with the generated client.
Sourcepub fn generate_server(
&self,
service: &impl Service,
proto_path: &str,
) -> TokenStream
pub fn generate_server( &self, service: &impl Service, proto_path: &str, ) -> TokenStream
Generate server code based on Service.
This takes some Service and will generate a TokenStream that contains
a public module with the generated client.