Generate did file automatically

Is there a way to generate automatically the did file for the public query and update functions and types in Rust - as in Motoko - or the did file should really be edited manually?

@lwshang you’re working on this right now. What’s the current best practice?

Hi @peterparker,

We currently don’t have a clean way to auto generate candid for rust canister.

While there is a workaround as described in this post:

The SDK team envisions a redesign of Rust CDK which can provide more ergonomic developer experience. Auto generating candid is one of the features we plan to provide. The work is still in early stage.

Thanks for the feedback, looking forward to it then.

Workaround described in related post did not work out for me, I got an empty service : {} as outcome. Did not dig that deep in though.

I suspect you also need to add this to the methods you’d like to include in the generated Candid:

use ic_cdk::export::candid::candid_method;
1 Like

Good catch! The service gets filled.

type Asset = record { key : text; value : vec nat8 };
type State = record { owner : text; assets : vec record { text; Asset } };
service : { get : () -> (State) query }


1 Like