palantir / conjure-rust

Conjure support for Rust
Apache License 2.0
20 stars 11 forks source link

Use staged_builder #349

Closed sfackler closed 6 months ago

sfackler commented 6 months ago

Before this PR

We directly codegened staged builder logic, with each stage being a separate type.

Constructors were generated for all types which had 3 or fewer fields, and the constructor required all of them.

After this PR

==COMMIT_MSG== Object builders are now generated with #[staged_builder]. Constructors now ignore optional fields. ==COMMIT_MSG==

The builders generated by #[staged_builder] are much cleaner in rustdoc output, as all of the setters are rendered on one page: https://docs.rs/staged-builder/latest/staged_builder/example_person/struct.Builder.html

Possible downsides?

The constructor change will be a someone nontrivial source break, but should make wire-compatible evolution of Conjure objects less likely to be a Rust-incompatible change.

Closes #347 Closes #348

changelog-app[bot] commented 6 months ago

Generate changelog in changelog-dir>`changelog/@unreleased`</changelog-dir

What do the change types mean? - `feature`: A new feature of the service. - `improvement`: An incremental improvement in the functionality or operation of the service. - `fix`: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way. - `break`: Has the potential to break consumers of this service's API, inclusive of both Palantir services and external consumers of the service's API (e.g. customer-written software or integrations). - `deprecation`: Advertises the intention to remove service functionality without any change to the operation of the service itself. - `manualTask`: Requires the possibility of manual intervention (running a script, eyeballing configuration, performing database surgery, ...) at the time of upgrade for it to succeed. - `migration`: A fully automatic upgrade migration task with no engineer input required. _Note: only one type should be chosen._
How are new versions calculated? - ❗The `break` and `manual task` changelog types will result in a major release! - 🐛 The `fix` changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease. - ✨ All others will result in a minor version release.

Type

- [ ] Feature - [ ] Improvement - [ ] Fix - [x] Break - [ ] Deprecation - [ ] Manual task - [ ] Migration

Description

Object builders are now generated with `#[staged_builder]`. Constructors now ignore optional fields. **Check the box to generate changelog(s)** - [x] Generate changelog entry