Skip to content

Conversation

@buffalojoec
Copy link
Contributor

@buffalojoec buffalojoec commented Sep 26, 2025

The Rust renderer supports a configuration object for determining what traits you'd like to be generated in the #[derive(..)] attribute of each type. In this config, devs can specify what traits they want to be always implemented (ie. baseDefaults) or implemented behind a feature flag.

However, there are two issues with the current implementation:

  • Serde can be included as a baseDefault, meaning it's not behind a feature flag, but the field attribute is still generated as #[cfg_attr(feature = "serde")].
  • If serde is omitted from the traitOptions, the field attributes are still generated.

This PR adds a getSerdeFieldAttribute that solves both issues. It evaluates all traits, including those behind a feature flag, and determines how to write the field attribute, if at all.

@changeset-bot
Copy link

changeset-bot bot commented Sep 26, 2025

🦋 Changeset detected

Latest commit: b26e054

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@codama/renderers-rust Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@buffalojoec buffalojoec force-pushed the optional-serde-callsites-rebaser branch from 0778d8d to b26e054 Compare September 26, 2025 14:06
Copy link
Member

@lorisleiva lorisleiva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you!

@lorisleiva lorisleiva merged commit 33a297d into codama-idl:main Sep 26, 2025
4 checks passed
@github-actions github-actions bot mentioned this pull request Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants