Expand description
Canonical bytes and digests (spec 002, 3.3).
Canonical bytes are written by this module’s own writer rather than by
serde_json’s map order, so the form does not depend on whether any crate
in the build enables serde_json/preserve_order: object keys are sorted by
byte order, there is no insignificant whitespace, strings use serde_json
escaping, and a fractional or exponent number is refused.
The record canonical form (spec 004, 5.6) differs only for numbers held
as binary64, which write_binary64 writes itself rather than through
serde_json’s formatter, whose digit choice at exact ties differs. It is
for backend outputs, run records, judgments, reports and replay
documents. A document without a binary64 number has the same bytes in
both forms.
Enums§
- Canonical
Error - Why a value has no canonical form.
Functions§
- canonical_
bytes - The canonical bytes of any serializable value.
- canonical_
value_ bytes - The canonical bytes of an already-built JSON value.
- record_
canonical_ bytes - The record canonical bytes of a typed document (spec 004, 5.6); the
form is defined for typed documents only, never for an untyped JSON
value, whose numbers lose the binary64 distinction. Refused
unless they parse back to an equal document whose record canonical bytes
are the same bytes: a non-finite number, which serializes as
null, never gets a form. - tagged_
digest sha256:and the lowercase hex SHA-256 oftag || 0x00 || bytes.- write_
binary64 - Write a finite binary64 (spec 004, 5.6): the shortest round-trip digits
nearest the exact value, exact ties to the larger magnitude, as Rust’s
core::fmtshortest mode gives them; plain notation for a decimal exponentewith-5 <= e < 16and at least one fractional digit, otherwised[.ddd]e+Nord[.ddd]e-N; zero as0.0or-0.0.