Available on crate feature
std and non-WebAssembly only.Expand description
Zero-Copy TCP Framing Pipeline
Problem: the old approach did data.clone() + encrypt_in_place() +
write(len) + write(data) = 2 syscalls + 1 clone per message. TLS 1.3
(rustls) does the equivalent in a single internal write.
Solution: prepend a 4-byte length header, encrypt the payload in place into the
same buffer, then issue a single write_all() — one syscall, no clone. Multiple
chunks / frames are coalesced into one buffer before the write.
NOTE: this is a helper for the native TCP path; the production SessionTransport
over TCP is TcpSessionTransport (in api/tcp_transport.rs), which carries the
same 4-byte big-endian length prefix. PhantomUDP does its own framing elsewhere.
Structs§
- Frame
Reader - Zero-copy frame reader — reads and decrypts from TCP stream
- Frame
Writer - Zero-copy frame writer — encrypts and writes in a single syscall
Enums§
- Frame
Error - Frame errors
Constants§
- FRAME_
HEADER_ SIZE - Frame header size: 4 bytes for payload length (u32 BE)
- MAX_
FRAME_ PAYLOAD - Maximum frame payload size (before encryption)