serde.rs hand-writes what derive already does #34
Labels
No labels
kind
bug
kind
enhancement
kind
refactor
workflow
needs-info
workflow
needs-triage
workflow
ready-for-agent
workflow
ready-for-human
workflow
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
rosa/lucre#34
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What to build
serde.rshand-writesMoneyVisitor,MoneyField,MoneyFieldVisitor,ExchangeRateVisitor,ExchangeRateField, andExchangeRateFieldVisitor—around 154 lines. What they implement is what
#[derive(Deserialize)]does bydefault: every named field required, unrecognized fields skipped, a repeated
field rejected.
Turn on serde's
derivefeature under the crate's existing optionalserdefeature, and read each type through a private shadow struct that derives
Deserialize.ExchangeRatekeeps its check that the rate is above zero.Figurestays as it is: it holds the decimal shapes under this crate's controlrather than rust_decimal's, which is a decision worth keeping.
A crate that does not turn on the
serdefeature gains no new dependency.The wire format does not change. The existing round-trip tests are the proof.
Acceptance criteria
MoneyandExchangeRateread through derived shadow structsderiveis enabled only under the optionalserdefeaturemise run cipassesBlocked by
None — can start immediately.