Skip to main content

Module wire

Module wire 

Source
Expand description

The id wire contract (decimal-string u64) shared by every JS-facing binding of these types — one source of truth for wire::ID_KEYS instead of a Node/WASM copy each. JSON-tree helpers for the id wire contract shared by every JS-facing binding (Node, WASM) of the context types: a u64 id crosses as a decimal string, because JS number loses precision above 2^53.

Node and WASM independently need the exact same tree walk over a serialized CompiledContext — one to turn outgoing ids into strings, the other to turn incoming strings back into numbers before deserializing. Living here once (instead of copy-pasted per binding) means [ID_KEYS] has a single source of truth: a future id field added to a context type only needs updating in one place, not silently missed in whichever binding a copy-paste forgot.

Deliberately String-erred, not binding-specific: this crate depends on neither napi nor wasm-bindgen, so each binding maps the String error to its own error type at the call site.

Constants§

ID_KEYS
Object keys whose u64 values (or arrays of them) must cross to JS as decimal strings. Token counts stay numbers: they are bounded far below 2^53 by the budget caps.

Functions§

parse_fragment_id_strings
Accept fragments[].id in decimal-string form by rewriting it to the numeric wire form. The other ID_KEYS never appear in a compile request, only in the output — a blanket rule over every id key would corrupt caller metadata that happens to use that name.
parse_id_fields
The inverse of stringify_id_fields: recursively rewrite every ID_KEYS field given in decimal-string form back into the numeric form the domain types deserialize. Non-string id values pass through untouched (serde reports them with its own error).
stringify_id_fields
Recursively rewrite every ID_KEYS field of a serialized context wire value into its decimal-string form.