Skip to main content

Module wire

Module wire 

Source
Expand description

HiveLLM binary RPC wire layer — wire v1, frozen.

One frame is u32 LE length + MessagePack body; the body is a Request or Response in rmp-serde’s externally-tagged encoding over the 8-variant Value model. The normative byte definition lives in docs/spec/ (transplanted family spec); this crate is bound to it by docs/specs/SPEC-001-wire-format.md (WIRE-xxx requirements).

Canonicalization over the donor implementations (SPEC-001 §2):

  • Bytes is emitted as MessagePack bin (WIRE-010) — ~33% smaller than the int-array form every pre-Thunder Rust server emits — while the legacy int-array form is accepted on decode forever (WIRE-011).
  • Request/Response are emitted as array-encoded structs (WIRE-012); map-shaped requests decode fine (WIRE-013, rmp-serde leniency).

This crate is pure: no sockets, no product knowledge (WIRE-030). Async frame helpers are available behind the tokio feature.

Re-exports§

pub use config::Config;

Modules§

config
Protocol configuration (SPEC-002) — the declarative description of how one application uses the shared wire. Pure data: the codec never depends on it; thunder::client / thunder::server drive their behavior from it.

Structs§

Request
One RPC request (WIRE-001). id is client-chosen and echoed back; many requests multiplex over one connection. Serialized as an array (WIRE-012); map-shaped requests decode too (WIRE-013).
Response
One RPC response (WIRE-001). result is Ok(value) or an error string; v1 carries no structured error object — conventions are prefix-based and profile-driven (WIRE-040).

Enums§

DecodeError
Errors from the sync decoder.
Value
The wire value model (WIRE-002) — byte-compatible with the value models the family shipped before Thunder, by construction.

Constants§

DEFAULT_MAX_FRAME_BYTES
Default frame-body cap: 64 MiB, validated against the length prefix before any allocation (WIRE-020). Operators tune it per profile.
PUSH_ID
Reserved frame id for server-initiated push frames (WIRE-005).

Functions§

decode_frame
Decode one frame from a byte slice using DEFAULT_MAX_FRAME_BYTES.
decode_frame_with_limit
Decode one frame, rejecting bodies larger than max before the body is even inspected (WIRE-020/021).
encode_frame
Encode a message into one complete frame (u32 LE length + body).
read_frame
Read one frame; returns the decoded value and the frame size in bytes (4 + body — the metrics input, SRV-007). The cap is checked between reading the prefix and allocating the body (WIRE-020).
read_request
Read one Request with the default cap.
read_request_with_limit
Read one Request with a caller-supplied cap (server hot path).
read_response
Read one Response with the default cap.
read_response_with_limit
Read one Response with a caller-supplied cap.
write_frame
Encode and write one frame; returns the frame size written.
write_request
Write one Request frame.
write_response
Write one Response frame.