Skip to main content

Module codec

Module codec 

Source
Available on crate feature transport only.
Expand description

§Parse-on-demand codec (Task 0.3a)

The data-plane spine frames bytes into a WorkBatch WITHOUT parsing (Task 0.2). A transform / router that needs to read a field parses on demand – and it should not care whether the record arrived as JSON or MsgPack. This module is that parse step.

§Native, no JSON bridge

There is no rmp_serde -> serde_json::Value -> serde_json::to_vec -> sonic_rs bridge anywhere on the parse path – that double-parse-and- re-serialise was killed in Phase 0.7c (the engine parse.rs MsgPack path now walks rmpv straight into a sonic_rs::Value). Both this codec and the engine decode natively:

  • JSON is parsed once with sonic_rs (SIMD, AVX2/NEON).
  • MsgPack is parsed once with rmpv – the schema-less Value decoder from the same 3Hren/msgpack-rust workspace as rmp-serde. No intermediate serde_json::Value, no JSON re-serialise.

§Unified routing-field accessor

A router keys off ONE field (_table, org_id, …) and must not branch on wire format. ParsedPayload exposes a format-agnostic accessor:

Scope: top-level object-key lookup only. No deep JSON-path – routing keys live at the top level, and a deep-path query is a separate concern that YAGNI keeps out of the hot routing path.

See docs/MIGRATIONS.md (codec consolidation: native rmpv, JSON bridge removed) and docs/SELF-REGULATION.md for where this codec sits in the WorkBatch data-plane spine. The block contract is in WorkBatch.

Enums§

CodecError
A parse failure, tagged by the format that failed.
FieldRef
A borrowed view of one routing field, format-agnostic.
ParsedPayload
A parsed payload, retaining its native value representation.

Functions§

parse
Parse a framed payload into a native ParsedPayload.
to_json_bytes
Serialise a JSON value to bytes via sonic_rs (SIMD), no bridge.
to_msgpack_bytes
Serialise a MsgPack value to bytes via NATIVE rmpv::encode::write_value.