ts_wire/lib.rs
1// Copyright (c) 2026 LightSeek Foundation
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19// SOFTWARE.
20
21//! TokenSpeed's engine IPC schema and its msgpack codec.
22//!
23//! The messages a frontend and the engine exchange over ZMQ, encoded exactly
24//! as the Python side encodes them (`msgspec` structs in
25//! `python/tokenspeed/runtime/engine/io_struct.py` and `zmq_wire.py`). Golden
26//! fixtures written by the Python encoder keep the two sides in step: every
27//! fixture decodes here and re-encodes byte for byte (`tests/conformance.rs`).
28//!
29//! Field order of the array-layout structs is the wire contract. To add a
30//! field, append it on both sides with a default and regenerate the fixtures.
31
32#![forbid(unsafe_code)]
33
34#[macro_use]
35pub mod codec;
36pub mod control;
37pub mod error;
38pub mod frames;
39pub mod handshake;
40pub mod msgpack;
41pub mod multimodal;
42pub mod output;
43pub mod request;
44pub mod sampling;
45pub mod tensor;
46pub mod value;
47
48pub use codec::{decode_bytes, decode_frames, encode_frames, Dict, StrOrList, Wire};
49pub use control::{ControlOutput, ControlRequest};
50pub use error::{Error, Result};
51pub use frames::{engine_identity, EngineOutput, EngineRequest, ENGINE_CORE_DEAD};
52pub use handshake::{
53 EngineCoreReadyResponse, HandshakeAddresses, HandshakeInitMessage, ReadyMessage,
54};
55pub use multimodal::{
56 EncodeRequest, Modality, MultimodalDataItem, MultimodalInputs, ShmTensorHandle,
57};
58pub use output::{BatchTokenIDOutSlim, RequestOutput};
59pub use request::{SessionParams, TokenizedGenerateReqInput};
60pub use sampling::SamplingParams;
61pub use tensor::Tensor;
62pub use value::Value;