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

Builder for the generic code generation of server and clients.

Implementations§

source§

impl CodeGenBuilder

source

pub fn new() -> Self

Create a new code gen builder with default options.

source

pub fn emit_package(&mut self, enable: bool) -> &mut Self

Enable code generation to emit the package name.

source

pub fn attributes(&mut self, attributes: Attributes) -> &mut Self

Attributes that will be added to mod and struct items.

Reference Attributes for more information.

source

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.

source

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.

source

pub fn disable_comments( &mut self, disable_comments: HashSet<String> ) -> &mut Self

Disable comments based on a proto path.

source

pub fn use_arc_self(&mut self, enable: bool) -> &mut Self

Emit Arc<Self> instead of &self in service trait.

source

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.

source

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.

source

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

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for CodeGenBuilder

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.