Skip to main content

Module codec

Module codec 

Source
Expand description

JSON codec for records (feature remote, no_std + alloc compatible).

A record’s value T often has to cross a type-erasure boundary into a wire format. AimX uses owned JSON bytes on its outbound record hot paths and serde_json::Value where a tree is still required; no_std connectors and local record.latest()?.as_json() calls use the same bridge. This module provides both forms without requiring std — serde_json runs on alloc alone, so embedded targets can opt in via the remote feature.

Two layers:

  • RemoteSerialize — the capability trait. Blanket-implemented for every serde type, so any T: Serialize + DeserializeOwned gets a JSON codec for free. This is the AimX/connector analogue of the data-contract traits (Streamable, Linkable). It lives in aimdb-core rather than aimdb-data-contracts because that crate depends on aimdb-core, not the reverse — bounding a core method on Streamable would be a dependency cycle. Every Streamable type satisfies RemoteSerialize automatically.

  • JsonCodec — the object-safe, type-erased storage form, with the zero-sized SerdeJsonCodec implementation. A record stores Option<Arc<dyn JsonCodec<T>>>; the AimX read/write/subscribe paths and RecordValue::as_json route through it. This mirrors the connector layer’s fused SerializedSource / IngestFn callbacks.

Structs§

SerdeJsonCodec
Zero-sized serde-backed JsonCodec.

Traits§

JsonCodec
Type-erased JSON codec for one record type.
RemoteSerialize
A record type that can be encoded to / decoded from the JSON wire format.