feat(build): Add CodeGenBuilder (#1154)
This commit adds a new `CodeGenBuilder` that replaces the client/server generate fn with a builder stlye that allows adding config items in an non-breaking way. This also deprecates both of the client/server generate fn in favor of the builder ones.
This commit is contained in:
@@ -9,6 +9,7 @@ use quote::{format_ident, quote};
|
||||
///
|
||||
/// This takes some `Service` and will generate a `TokenStream` that contains
|
||||
/// a public module with the generated client.
|
||||
#[deprecated(since = "0.8.3", note = "Use the CodeGenBuilder::generate_client")]
|
||||
pub fn generate<T: Service>(
|
||||
service: &T,
|
||||
emit_package: bool,
|
||||
@@ -16,6 +17,25 @@ pub fn generate<T: Service>(
|
||||
compile_well_known_types: bool,
|
||||
build_transport: bool,
|
||||
attributes: &Attributes,
|
||||
) -> TokenStream {
|
||||
generate_internal(
|
||||
service,
|
||||
emit_package,
|
||||
proto_path,
|
||||
compile_well_known_types,
|
||||
build_transport,
|
||||
attributes,
|
||||
&HashSet::default(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn generate_internal<T: Service>(
|
||||
service: &T,
|
||||
emit_package: bool,
|
||||
proto_path: &str,
|
||||
compile_well_known_types: bool,
|
||||
build_transport: bool,
|
||||
attributes: &Attributes,
|
||||
disable_comments: &HashSet<String>,
|
||||
) -> TokenStream {
|
||||
let service_ident = quote::format_ident!("{}Client", service.name());
|
||||
|
||||
Reference in New Issue
Block a user