Expand description
Adjustment reports for lossy writes.
Ported from ~/dev/omnist/omnist/report.py. Writing a crate::document::Doc
to a format that can’t hold every value losslessly (JSON has no native
date/time type and no NaN/Infinity; TOML has no null) means the
writer has to adjust the data. Each adjustment is recorded as an
Adjustment in a WriteReport rather than lost silently. The same
report drives three behaviours, matching the Python reference exactly:
- lenient (default) – adjust and move on; the caller may ignore the report.
- inspect – pass a
report: Option<&mut WriteReport>to a writer (or call a format’scheck_*) to see what changed without stopping. - strict (
strict: true) –finish_writereturnscrate::error::WriteError(carrying the report) if anything had to be adjusted.
Each adjustment has a Severity: Warning (conventional/recoverable –
a date written as a string) or Error (likely to surprise or corrupt –
NaN written as JSON null). strict ignores severity and raises on
anything, matching Python’s finish_write.
Structs§
- Adjustment
- One thing a writer changed to make the data fit the target format.
Mirrors Python’s
AdjustmentNamedTuplefield-for-field. - Write
Report - Everything a writer adjusted. Mirrors Python’s
WriteReport: truthy (seeWriteReport::is_ok) when there are no error-severity entries – warnings alone are fine.
Enums§
- Severity
- How surprising/lossy a single
Adjustmentis.strictmode raises on either severity; onlyWriteReport::is_ok(Python’s__bool__) distinguishes them.
Functions§
- finish_
write - The standard
strict/reporthandling every format writer applies to its own accumulatedWriteReport, mirroring Python’sfinish_write.