Skip to main content

Module codec

Module codec 

Source
Expand description

Codec abstraction for tier serialization (Phase 14.6 — DS-14-storage Q4 lock, M4.B 2026-05-10).

Tiers parameterize over a Codec<T> to encode values before backend.write and decode bytes after backend.read. JsonCodec is the default (zero-sized, parity-encoded to match TS jsonCodec). DagCbor / zstd codecs land in later sub-slices when content-addressing scenarios surface.

§Parity with TS jsonCodec

TS jsonCodec.encode runs values through stableJsonString — recursive key-sort + JSON.stringify(_, undefined, 0). JsonCodec mirrors via serde_json::to_value (BTreeMap-backed Map, sorted iteration) → serde_json::to_vec. Snapshot files written by the Rust impl are byte-identical to TS for the value schemas Graph emits (ASCII keys, integer numerics, no floats).

Structs§

JsonCodec
Zero-sized JSON codec — UTF-8 text, canonical (sorted-key) JSON. Matches TS jsonCodec byte-for-byte on the value schemas Graph emits.

Enums§

CodecError
Codec encode / decode failures. Stringified internally — the underlying serde_json::Error carries position info in its Display impl.

Traits§

Codec
Codec for tier serialization. Tiers call encode(value) before backend.write and decode(bytes) after backend.read. name + version surface at the tier level for format_version migration (Q4).