Struct tonic_build::CodeGenBuilder
source · 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 knonw 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.