dfinity / dfinity/candid

As a developer, I want to be able to customize the code generated by didc so that I don't have to do so with a sed script.

Open
#473 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
301
Forks
85
Avg merge
1h 4m
Merged PRs (30d)
4

Description

Is your feature request related to a problem? Please describe.
Currently I have to post-process the Rust code generated by .didc. The changes include:

  • Make types and their fields public, otherwise they cannot be used!
  • Comment out the header; I often use different imports and need different clippy rules.
  • Customize the list of traits applied to every struct.
  • ... and many other things.

Describe the solution you'd like
Rather than making a huge long list of customizations, I would like to suggest that to start with we introduce a structure for managing customizations.

In particular I would like to propose an options file that could be called like this:

didc bind --target rs --options optfile.did somefile.candid

or

didc bind --target rs --options <( echo stuff) somefile.candid

That options file could then, for example, contain record{ rust = record {header=false}} to suppress printing the Rust header.

Describe alternatives you've considered

  • Having a bunch of flags. I think this could get unwieldy.
  • Having an implicit location for an options file. We could do this but then we would still want an override.

Additional context

Note: If approved in principle I would be happy to implement this and then make further proposals, one for every option.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the didc bind command for the Rust target and trace the generated Rust output path. Define the options-file format and how options such as suppressing the header are applied; done means bind accepts --options and the requested Rust customization is demonstrably supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.