# Internet
A networking library providing codecs, in-place parsing and mutation.
## Architecture
### Mappings: In-Place Parsing and Mutation
Access protocol fields directly on the underlying buffer with zero allocations:
```rust
use internet::ietf::udp::{HeaderMapping, Port};
// Parse in-place
let udp = HeaderMapping::new(&[0xaa, 0xaa, 0xbb, 0xbb, 0x66, 0x66, 0x00, 0x00]);
let src_port = udp.read_source_port();
let dst_port = udp.read_destination_port();
println!("{src_port:#?}, {dst_port:#?}");
// Mutate in-place
let udp_mut_bytes = &mut [0xaa, 0xaa, 0xbb, 0xbb, 0x66, 0x66, 0x00, 0x00];
let mut udp = HeaderMapping::new(udp_mut_bytes);
udp.write_source_port(Port::from(443)).unwrap();
```
### Codecs: Type-Safe Serialization and Deserialization
High-level protocol types with `encode`/`decode` methods:
```rust
use internet::ietf::tls1_3::{Alert, AlertDescription};
use internet::{Codec, Cursor};
// Decode from buffer
let mut alert = Alert::decode(&mut Cursor::new(&[0x02, 0xA]), ()).unwrap();
alert.description = AlertDescription::DecodeError;
println!("{alert:#?}");
// Encode to buffer
let mut writer = Cursor::new(vec![]);
alert.encode(&mut writer, ()).unwrap();
```
## Scope
This library provides **zero-copy**, **type-safe** implementations
of **dozens of internet protocols** across all network layers:
- **Layer 2 (Data Link)**: Ethernet, VLAN, ARP
- **Layer 3 (Network)**: IPv4, IPv6, ICMPv4/6, IGMP (v1-3), NDP, MLD (v1/2), SLAAC
- **Layer 4 (Transport)**: TCP, UDP, QUIC (v1/2)
- **Layer 5-7 (Application)**: HTTP/1.1, HTTP/2, HTTP/3, TLS (1.0-1.3), DHCPv4/6
Future releases will expand coverage to **hundreds of protocols**
including BGP, DNS, SMTP, and 3GPP mobile standards.
## Modules
- [`egpp`](https://docs.rs/internet/0.1.0/internet/egpp/index.html) — 3GPP mobile protocols (LTE, 5G, etc.)
- [`ieee`](https://docs.rs/internet/0.1.0/internet/ieee/index.html) — IEEE family (Ethernet, VLAN, Wi-Fi, etc.)
- [`ietf`](https://docs.rs/internet/0.1.0/internet/egpp/ietf.html) — IETF protocols (IP, TCP, UDP, HTTP, TLS, etc.)
## Core Traits
- [`Buf`](https://docs.rs/internet/0.1.0/internet/trait.Buf.html), [`BufMut`](https://docs.rs/internet/0.1.0/internet/trait.BufMut.html) — Buffer traits for zero-copy operations
- [`Codec`](https://docs.rs/internet/0.1.0/internet/trait.Codec.html) — Trait for type-safe encoding/decoding
- [`Cursor`](https://docs.rs/internet/0.1.0/internet/struct.Cursor.html) — Cursor wrapper for buffer operations
## Design Goals
- **Zero-copy**: Parse packets without allocations
- **Type-safe**: Compile-time guarantees on protocol structure
- **Comprehensive**: Cover the entire internet protocol stack
- **Extensible**: Easy to add new protocols following the same pattern
## Status
This library is under active development. Currently implements **30+ protocols**
with more being added regularly.
**Unstable API** — Breaking changes expected until 1.0.0.
> Then more standards and protocols we met — then more ideas we got.
> Then more areas we explore — then more name spaces and conflicts we got.
> Then more goals we set — then more scales we got.
> Then more time we lived — then more times we changed.