Skip to main content

Module report

Module report 

Source
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’s check_*) to see what changed without stopping.
  • strict (strict: true) – finish_write returns crate::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 Adjustment NamedTuple field-for-field.
WriteReport
Everything a writer adjusted. Mirrors Python’s WriteReport: truthy (see WriteReport::is_ok) when there are no error-severity entries – warnings alone are fine.

Enums§

Severity
How surprising/lossy a single Adjustment is. strict mode raises on either severity; only WriteReport::is_ok (Python’s __bool__) distinguishes them.

Functions§

finish_write
The standard strict/report handling every format writer applies to its own accumulated WriteReport, mirroring Python’s finish_write.