Motoko binding is generated in the Motoko compiler, it’s not available in the Rust library, but we can easily add one.
Rust binding may require some human intervention. I’m not sure the best way to solve these problems:
The fundamental difference between Candid typing and Rust is structural typing vs nominal typing. That is, when you create a struct/enum type in Rust, you have to give the type a name, which doesn’t necessarily exist in the did file, or may not the best name you want. There’s also the question of what traits to derive for each struct.
A candid type can map to multiple Rust types. For example, vec record { text; int } can map to Vec<(String, Int)>, HashMap<&str, Int>, or even &[Box<(Cow<str>, Arc<i128>)>].
syntax highlighting
Not sure what syntax highlighter you are using, but we have a syntax highlighter for did files:
Curious – for stuff like “nns-ui”, I couldn’t find it in any open dfinity repo. How did you able to locate those canisters and get their interfaces?
I did the same work for candid-kt. If you’re interested we could arrange a call or something and I could walk you through the library and its code-generator logic.
I think it is simpler to generate rust code than kotlin code, because we already have all the needed libraries like candid and agent-rs. In kotlin I had to implement them myself.
I just went with Github PRs since that’s the easiest to get started with. In the future, it could be a token-curated registry or a reputation-based wiki. This would be a good project for someone to build, hint hint!
For candid-kt, do you have anything that can convert did → kt in the browser?