thunder/wire/mod.rs
1//! HiveLLM binary RPC wire layer — **wire v1, frozen**.
2//!
3//! One frame is `u32 LE length` + MessagePack body; the body is a
4//! [`Request`] or [`Response`] in rmp-serde's externally-tagged encoding
5//! over the 8-variant [`Value`] model. The normative byte definition lives
6//! in `docs/spec/` (transplanted family spec); this crate is bound to it by
7//! `docs/specs/SPEC-001-wire-format.md` (`WIRE-xxx` requirements).
8//!
9//! Canonicalization over the donor implementations (SPEC-001 §2):
10//! - `Bytes` is emitted as MessagePack **bin** (WIRE-010) — ~33% smaller
11//! than the int-array form every pre-Thunder Rust server emits — while
12//! the legacy int-array form is accepted on decode forever (WIRE-011).
13//! - `Request`/`Response` are emitted as array-encoded structs (WIRE-012);
14//! map-shaped requests decode fine (WIRE-013, rmp-serde leniency).
15//!
16//! This crate is pure: no sockets, no product knowledge (WIRE-030). Async
17//! frame helpers are available behind the `tokio` feature.
18
19pub mod config;
20mod frame;
21mod value;
22
23pub use config::Config;
24pub use frame::{
25 decode_frame, decode_frame_raw, decode_frame_with_limit, encode_frame, DecodeError,
26};
27pub use value::{Request, Response, Value};
28
29#[cfg(feature = "tokio")]
30pub use frame::{
31 read_frame, read_request, read_request_with_limit, read_response, read_response_with_limit,
32 write_frame, write_request, write_response,
33};
34
35/// Reserved frame id for server-initiated push frames (WIRE-005).
36///
37/// Clients must never use it as a request id; servers refuse requests
38/// carrying it; client demultiplexers route it to the push hook.
39pub const PUSH_ID: u32 = u32::MAX;
40
41/// Default frame-body cap: 64 MiB, validated against the length prefix
42/// *before* any allocation (WIRE-020). Operators tune it per profile.
43pub const DEFAULT_MAX_FRAME_BYTES: usize = 64 * 1024 * 1024;