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
u64values (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[].idin decimal-string form by rewriting it to the numeric wire form. The otherID_KEYSnever appear in a compile request, only in the output — a blanket rule over everyidkey would corrupt caller metadata that happens to use that name. - parse_
id_ fields - The inverse of
stringify_id_fields: recursively rewrite everyID_KEYSfield 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_KEYSfield of a serializedcontextwire value into its decimal-string form.