Skip to main content

shuflr_wire/
lib.rs

1//! `shuflr-wire/1` protocol codec — pure framing / parsing with no I/O.
2//!
3//! Specced in `docs/design/005-serve-multi-transport.md` §3. This
4//! crate knows nothing about sockets, TLS, pyo3, or tokio. It turns
5//! [`Message`] values into bytes and back, with an xxh3 checksum on
6//! every non-handshake frame.
7//!
8//! The transport (PR-33) drives this codec from a
9//! `tokio::io::{AsyncReadExt, AsyncWriteExt}` loop; the `shuflr-
10//! client` Python wheel (PR-34b) uses it from a blocking `std::io`
11//! loop. Both sides use the same encode/decode pair — byte-for-byte
12//! compat is pinned by the proptest round-trip harness in tests/.
13
14#![forbid(unsafe_code)]
15#![deny(missing_debug_implementations)]
16
17pub mod codec;
18pub mod error;
19pub mod message;
20
21pub use codec::{
22    DecodeOptions, Decoder, HandshakeRole, MIN_FRAME_BYTES, encode, encode_handshake, encode_into,
23};
24pub use error::WireError;
25pub use message::{
26    AuthKind, BatchPayload, ChosenMode, ClientHello, HandshakeStatus, Kind, Message, ServerHello,
27    StreamErrorCode,
28};
29
30pub const MAGIC: [u8; 8] = *b"SHUFLRW1";
31pub const VERSION: u8 = 1;
32/// Server-side hard cap on any single message body. 005 §3.1. Chosen
33/// to exceed EDGAR's largest single-record frame (427 MiB) with
34/// headroom without leaving the door open for multi-GB pathological
35/// messages.
36pub const MAX_MESSAGE_BYTES: u32 = 512 * 1024 * 1024;