Skip to content

Commit

Permalink
 Add support for #[cfg(…)] attributes on rpc trait definition
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfariello authored and paulfariello-syn committed Feb 8, 2024
1 parent 403a633 commit 174f824
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion plugins/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ impl<'a> ServiceGenerator<'a> {
camel_case_idents,
arg_pats,
method_idents,
method_attrs,
..
} = self;

Expand All @@ -431,6 +432,7 @@ impl<'a> ServiceGenerator<'a> {
-> ::core::result::Result<#response_ident, ::tarpc::ServerError> {
match req {
#(
#( #method_attrs )*
#request_ident::#camel_case_idents{ #( #arg_pats ),* } => {
::core::result::Result::Ok(#response_ident::#camel_case_idents(
#service_ident::#method_idents(
Expand All @@ -453,6 +455,7 @@ impl<'a> ServiceGenerator<'a> {
camel_case_idents,
args,
request_names,
method_attrs,
..
} = self;

Expand All @@ -462,12 +465,16 @@ impl<'a> ServiceGenerator<'a> {
#[derive(Debug)]
#derive_serialize
#vis enum #request_ident {
#( #camel_case_idents{ #( #args ),* } ),*
#(
#( #method_attrs )*
#camel_case_idents{ #( #args ),* }
),*
}
impl ::tarpc::RequestName for #request_ident {
fn name(&self) -> &'static str {
match self {
#(
#( #method_attrs )*
#request_ident::#camel_case_idents{..} => {
#request_names
}
Expand Down

0 comments on commit 174f824

Please sign in to comment.