Skip to content

Commit

Permalink
support custom candid path for export_service (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyan-dfinity authored May 23, 2023
1 parent eb31f88 commit b9d6cbf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions rust/candid_derive/src/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ pub(crate) fn candid_method(attrs: AttributeArgs, fun: ItemFn) -> Result<TokenSt
Ok(quote! { #fun })
}

pub(crate) fn export_service() -> TokenStream {
pub(crate) fn export_service(path: Option<TokenStream>) -> TokenStream {
if let Some(meths) = METHODS.lock().unwrap().as_mut() {
let candid = candid_path(&None);
let candid = candid_path(&path);
let init = if let Some(opt_args) = INIT.lock().unwrap().as_mut() {
let res = opt_args.as_ref().map(|args| {
let args = args
Expand Down
8 changes: 6 additions & 2 deletions rust/candid_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ pub fn candid_method(attr: TokenStream, item: TokenStream) -> TokenStream {
}

#[proc_macro]
pub fn export_service(_: TokenStream) -> TokenStream {
func::export_service().into()
pub fn export_service(input: TokenStream) -> TokenStream {
if input.is_empty() {
func::export_service(None).into()
} else {
func::export_service(Some(input.into())).into()
}
}

#[inline]
Expand Down

0 comments on commit b9d6cbf

Please sign in to comment.