Automatically generate candid from rust sources

Try this

}

export_service!();

#[ic_cdk_macros::query(name = "__get_candid_interface_tmp_hack")]
fn export_candid() -> String {
    __export_service()
}

(taken from candid/lib.rs at a555d77704d691bb8f34e21a049d44ba0acee3f8 · dfinity/candid · GitHub).

It would probably a reasonable feature request for cdk-rs to provide all of the above under a single macro (expose_candid_interface()). This would especially be useful if the underlying interface changes – then people just have to recompile their canisters, but not change any code.

6 Likes