Stackforge Core
High-performance, zero-copy network packet manipulation library.
This crate provides the core networking primitives for the Stackforge framework, implementing a "Lazy Zero-Copy View" architecture for efficient packet processing.
Architecture
Unlike traditional packet parsing libraries that eagerly deserialize all fields into objects, Stackforge Core uses a lazy evaluation model:
-
Zero-Copy Buffers: Packets are stored as contiguous byte buffers using the
bytescrate's reference-countedBytestype. -
Index-Only Parsing: When parsing a packet, we only identify layer boundaries (where each protocol header starts and ends).
-
On-Demand Access: Field values are read directly from the buffer only when explicitly requested.
-
Copy-on-Write: Mutation triggers buffer cloning only when shared.
Example
use ;
use MacAddress;
use Ipv4Addr;
// Build an ARP request
let arp = who_has
.hwsrc
.psrc
.build;
// Parse an existing packet
let raw_bytes = vec!;
let eth = at_start;
assert_eq!;