Skip to main content

Module value

Module value 

Source
Expand description

CBOR typed input (ADR-023 amended by ADR-060) with RFC 8949 §4.2 Deterministic-Encoding canonical-form byte output.

CBOR canonicalization is not a streaming transform: §4.2.1 sorts map keys by the bytewise lexicographic order of their encoded keys, which needs per-map storage. The realization therefore materializes the canonical form once, in an alloc buffer (canonicalize), with no width / depth / count ceilings beyond the single MAX_CBOR_DEPTH native-stack overflow guard. The handle then flows through the pipeline as a zero-copy [TermValue::Borrowed] carrier and ψ₉ folds it through the σ-axis.

§RFC 8949 §4.2 Deterministic Encoding (the canonical form)

The canonicalizer accepts any well-formed CBOR data item and re-emits it under the deterministic-encoding rules:

  • Preferred (shortest) integer/argument encoding (§4.2.1 / §4.1): every head’s argument uses the fewest bytes (inline 0–23, then 1, 2, 4, 8).
  • Definite-length only (§4.2.1): indefinite-length byte/text strings, arrays, and maps in the input are folded to their definite-length canonical form.
  • Map keys sorted (§4.2.1) bytewise-lexicographically by their canonical encodings; duplicate keys are rejected.
  • Shortest-float / canonical NaN (§4.2.2): a float is emitted in the shortest of half / single / double that round-trips its value exactly; every NaN collapses to the canonical half-precision 0xf9 0x7e 0x00.

Exactly one top-level data item is admitted (trailing bytes are rejected).

Structs§

CborCarrier
Borrowed canonical-CBOR input handle (ADR-060 borrowed carrier). A thin, Copy borrow of canonical bytes produced by canonicalize; as_binding_value returns the Borrowed carrier zero-copy.

Functions§

canonicalize
Re-encode raw (any well-formed CBOR item) into its RFC 8949 §4.2 deterministic-encoding canonical form.