Expand description
kanonak-codec — the generic, ontology-independent codec runtime (Rust port).
Given a CodecSchema (the per-package metadata a generated SDK embeds) and a
set of typed nodes, it builds the canonical input model and content-addresses
it via kanonak-canonical (the same content-form the Python/TypeScript
references and the kanonak hash CLI produce). It also (de)serializes the
normalized-JSON wire form. Self-contained: carriers come from the schema’s
datatype URIs, and the resolved foundation URIs are embedded by the generator,
so hashing needs no runtime ontology resolution.
A node is a plain JSON object (serde_json::Map<String, serde_json::Value>) —
the $-envelope plus alias-collapsed local-name fields. A generated typed
model serializes to one. Note: serde_json::Value (the node field model) is
distinct from kanonak_canonical::Value (the canonical-input value enum).
Enums§
- Codec
Error - Errors raised by the codec runtime. Fails loudly — no fallbacks.
Functions§
- build_
package - Build the canonical input model: a subject per node + the synthesized
package-wrapper subject (raw label +
Packagetype), exactly the subject setkanonak hashproduces for the equivalent authored package. - canonical_
form - The canonical form (the
{subjects:[...]}JSON) of a package from nodes. - content_
hash - The
sha256:content hash of a package from nodes — matcheskanonak hash. - deserialize
- Parse normalized JSON into a typed node.
$-envelope keys and fields modeled on the node’s$typestay top-level; every other key is collected into$extraso a strongly-typed consumer round-trips it losslessly. - serialize
- Serialize a typed node to its normalized-JSON wire form.
$extraentries ride as sibling fields after the modeled ones; a modeled field wins a name collision ([JsonExtensionData]semantics). No$extrakey on the wire.
Type Aliases§
- Node
- A node is a JSON object.