Unexpected () response from Motoko call of a Rust service


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:

async fn foobar() -> String {    

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

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


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

let result = await service.foobar();


What would cause this issue?


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.