Skip to main content

sui_daemon_frame/
lib.rs

1//! sui-daemon-frame — async frame codec for the rkyv-over-UDS local protocol.
2//!
3//! ## Wire format
4//!
5//! ```text
6//! [magic : 4B = "SUI1"] [len : 4B u32 LE] [body : N bytes of rkyv-archived WireFrame]
7//! ```
8//!
9//! The magic + length prefix is what lets a misaligned reader fail fast.
10//! rkyv's own validation pass (`rkyv::access`) catches body-shape errors;
11//! this codec only enforces the framing envelope.
12//!
13//! ## Scope
14//!
15//! This crate is **transport-agnostic**: it codes against `tokio::io::Async{Read,Write}`,
16//! so the same primitives work for `UnixStream`, `TcpStream`, in-memory
17//! `DuplexStream` (great for tests), or any future Bytes-stream abstraction.
18//!
19//! ## Reuse surface
20//!
21//! - `sui-daemon::graph_server` — reads frames from each accepted client.
22//! - `sui-daemon-client` — writes requests + reads responses on a single
23//!   multiplexed connection.
24//! - Tests across the workspace — drive `DuplexStream` end-to-end without
25//!   touching the filesystem.
26//! - Future fuzzers — call [`read_frame`] on arbitrary bytes and assert
27//!   only framing-level invariants (rkyv validation is downstream).
28
29#![warn(clippy::pedantic)]
30#![allow(clippy::module_name_repetitions)]
31
32mod codec;
33mod error;
34
35pub use codec::{read_frame, write_frame, FrameCodec, MAX_FRAME_BODY_BYTES};
36pub use error::FrameError;
37
38// Re-export the wire frame type so callers don't need both crate deps for
39// the common case of "give me a frame, send me a frame."
40pub use sui_protocol::WireFrame;