Unexpected () response from Motoko call of a Rust service

Hi,

Let’s say that I have an endpoint whose interface is declared in a Candid file as:

service : {
  foobar : () -> (text);
}

Where the Rust implementation is:

#[update]
#[candid_method(update)]
async fn foobar() -> String {    
    "Hello".into()
}

Which after deploying a DFX Canister call to the endpoint outputs “Hello”, as expected:

> dfx canister call <Foobar Canister Id> foobar "()"

("Hello")

Although, when called via Motoko, returns “()”:

let result = await service.foobar();

Debug.print(debug_show(result));

What would cause this issue?

3 Likes

My first guess would be that the Motoko code was compiled against an incorrect Candid file, or the candid file evolved after its compilation. Otherwise, perhaps there is a bug.

Do you have a GH repo with both projects we could look at?

Thank you! Tested in the Playground separately and I can get the text, there’s no bug sorry.