nwd1 0.1.0

Binary framing protocol for QUIC / HTTP3 streams using NetId64 identifiers. Frame layout: MAGIC | LEN | ID(8B) | KIND(1B) | VER(8B) | PAYLOAD.
Documentation
# nwd1

**Binary framing protocol for QUIC / HTTP3 streams using [NetId64](https://crates.io/crates/netid64) identifiers.**

`nwd1` defines a minimal, endian-safe, fixed-layout frame format suitable for both QUIC and HTTP/3 transports.  
It is designed to be efficient, testable, and transport-agnostic — a foundation for reliable streaming protocols.

> `nwd1` is not a full network protocol — it is the *binary frame foundation*  
> on which higher-level communication systems can be built.  
> It defines how data is shaped and identified, not what it means.


---

### 🧱 Frame Layout

```
MAGIC (4B) | LEN (4B) | ID (8B) | KIND (1B) | VER (8B) | PAYLOAD (variable)
```

> **Note:** The `|` characters shown above are *visual separators only*.

> They are **not present in the actual binary data** — the frame is a continuous byte stream.

| Field       | Size     | Description                                                                                  |
|-------------|----------|----------------------------------------------------------------------------------------------|
| **MAGIC**   | 4 bytes  | Constant header `b"NWD1"`. Used to identify the protocol.                                    |
| **LEN**     | 4 bytes  | Total length of the following bytes (big-endian `u32`).                                      |
| **ID**      | 8 bytes  | 64-bit network ID ([NetId64]https://crates.io/crates/netid64) → `KIND \| NODE \| COUNTER`. |
| **KIND**    | 1 byte   | Frame type (application-defined).                                                            |
| **VER**     | 8 bytes  | Protocol or schema version (`u64`, BE).                                                      |
| **PAYLOAD** | variable | Raw binary content.                                                                          |

---

### ⚙️ Example

```rust
use nwd1::{Frame, encode, decode};
use netid64::NetId64;
use bytes::Bytes;

let frame = Frame {
id: NetId64::make(1, 7, 42),
kind: 1,
ver: 1,
payload: Bytes::from_static(b"hello"),
};

// Encode to binary
let data = encode( & frame);

// Decode back
let decoded = decode( & data).unwrap();
assert_eq!(decoded.id.raw(), frame.id.raw());
assert_eq!(decoded.payload, frame.payload);
```