Expand description
§tokilake-smux
Wire-compatible smux protocol implementation for Rust.
Zero-overhead design following monolake patterns:
- Generic over transport (
AsyncRead + AsyncWrite), noBox<dyn> impl Futurein trait returns, noasync_traitcrate- Channel-based stream multiplexing
§Protocol
Header format (8 bytes, little-endian):
| VERSION (1B) | CMD (1B) | LENGTH (2B) | STREAM_ID (4B) |Commands: SYN(0), FIN(1), PSH(2), NOP(3), UPD(4)
§Usage
ⓘ
use tokilake_smux::{Session, Config};
// Server side
let mut session = Session::server(stream, Config::default());
let mut stream = session.accept().await?;
// Client side
let mut session = Session::client(stream, Config::default());
let mut stream = session.open().await?;Structs§
- Config
- SMUX session configuration.
- Frame
- A decoded smux frame.
- Session
- A multiplexed session over an underlying transport.
- Stream
- A multiplexed stream within a session.
Constants§
- HEADER_
SIZE - Header size in bytes: version(1) + cmd(1) + length(2) + stream_id(4).
- MAX_
PAYLOAD_ SIZE - Maximum payload size (u16::MAX).
- VERSION_
1 - Protocol version 1.
- VERSION_
2 - Protocol version 2 (adds flow control).