Skip to main content

po_wire/
lib.rs

1//! # po-wire
2//!
3//! **Zero-dependency, `no_std` wire format codec for Protocol Orzatty (PO).**
4//!
5//! This crate provides the binary framing layer — encoding and decoding frame
6//! headers with QUIC-style VarInt fields. It is the foundation of the PO stack:
7//! every byte that crosses the network goes through `po-wire`.
8//!
9//! ## Quick Start
10//!
11//! ```rust
12//! use po_wire::{FrameHeader, FrameType};
13//!
14//! // Encode a data frame header
15//! let header = FrameHeader::data(0, 13); // channel 0, 13-byte payload
16//! let mut buf = [0u8; 32];
17//! let header_len = header.encode(&mut buf).unwrap();
18//!
19//! // Decode it back
20//! let (decoded, consumed) = FrameHeader::decode(&buf[..header_len]).unwrap();
21//! assert_eq!(decoded.payload_len, 13);
22//! ```
23//!
24//! ## Features
25//!
26//! - **Zero dependencies**: No allocator needed. Pure `core` Rust.
27//! - **`no_std` compatible**: Runs on WASM, embedded, anywhere.
28//! - **Compact**: Minimum 4-byte header for small messages.
29//! - **QUIC VarInt**: RFC 9000 §16 variable-length integer encoding.
30
31#![no_std]
32
33pub mod error;
34pub mod varint;
35pub mod frame_type;
36pub mod header;
37
38// --- Public re-exports for ergonomic usage ---
39pub use error::WireError;
40pub use frame_type::FrameType;
41pub use header::{FrameHeader, FrameFlags};