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:
@@ -10,12 +10,30 @@ use syn::{Ident, Lit, LitStr};
|
||||
///
|
||||
/// This takes some `Service` and will generate a `TokenStream` that contains
|
||||
/// a public module containing the server service and handler trait.
|
||||
#[deprecated(since = "0.8.3", note = "Use CodeGenBuilder::generate_server")]
|
||||
pub fn generate<T: Service>(
|
||||
service: &T,
|
||||
emit_package: bool,
|
||||
proto_path: &str,
|
||||
compile_well_known_types: bool,
|
||||
attributes: &Attributes,
|
||||
) -> TokenStream {
|
||||
generate_internal(
|
||||
service,
|
||||
emit_package,
|
||||
proto_path,
|
||||
compile_well_known_types,
|
||||
attributes,
|
||||
&HashSet::default(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn generate_internal<T: Service>(
|
||||
service: &T,
|
||||
emit_package: bool,
|
||||
proto_path: &str,
|
||||
compile_well_known_types: bool,
|
||||
attributes: &Attributes,
|
||||
disable_comments: &HashSet<String>,
|
||||
) -> TokenStream {
|
||||
let methods = generate_methods(service, proto_path, compile_well_known_types);
|
||||
|
||||
Reference in New Issue
Block a user