Expand description
JSON-RPC 2.0 host <-> worker types + the versioned init handshake (spec §5).
Structs§
- Init
Announce - The worker’s first frame after connect (spec §5 init handshake). Carries the connection token (§6): the host generated it and passed it to the worker out-of-band (a 0600 file); the host verifies it here to reject any other local process that raced the loopback port.
- Json
RpcVersion - A ZST that (de)serializes as the constant string “2.0”, rejecting anything else.
- RpcNotification
- A JSON-RPC 2.0 notification (no
id). The worker’s init handshake is a notification —{ jsonrpc:"2.0", method:"worker/init", params:<InitAnnounce> }— so the first frame rides the SAME JSON-RPC parse path as every later frame (spec §5): the host reads frame 1, parses it as a notification, checksmethod == INIT_METHOD, and deserializesparamsasInitAnnounce.InitAnnounceis never sent as a naked object. - RpcRequest
- A JSON-RPC 2.0 request (host -> worker).
Enums§
- RpcId
- JSON-RPC 2.0 id: a number, a string, or null. Null is required by JSON-RPC 2.0 §5 on an error response to a request whose id couldn’t be determined (parse error / invalid request), so the host must be able to receive it — otherwise a worker’s parse-error reply fails to deserialize and its error is silently swallowed. (The host never sends a null id.)
- RpcResponse
- A JSON-RPC 2.0 response (worker -> host):
resultXORerror, never both, never neither (JSON-RPC 2.0 §5). Modeled as an untagged enum of two complete structs so the illegal states are unrepresentable. Deliberately NOT#[serde(flatten)]over an untagged inner enum — that serde combination double-buffers (flatten → map, untagged →Content) and is a known deserialize failure mode (fails outright or degrades integers to floats).
Constants§
- INIT_
METHOD - The method name of the worker’s init-handshake notification (spec §5).
- PROTOCOL_
VERSION - The protocol version this host speaks. The worker must announce a matching value in its init frame, else the host rejects it (WORKER_INCOMPATIBLE).