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.
Trait Implementations§
source§impl Debug for CodeGenBuilder
impl Debug for CodeGenBuilder
Auto Trait Implementations§
impl Freeze for CodeGenBuilder
impl RefUnwindSafe for CodeGenBuilder
impl Send for CodeGenBuilder
impl Sync for CodeGenBuilder
impl Unpin for CodeGenBuilder
impl UnwindSafe for CodeGenBuilder
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> 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