derivefeature is not yet available — coming in v0.2.0.
zerec
Minimal zero-copy binary codec for Rust.
No schema files. No runtime reflection. No type tags on the wire. Just bytes.
Quick start
[]
= { = "0.1", = ["derive"] }
use ;
Features
| Feature | What it enables |
|---|---|
derive |
#[derive(Encode, Decode)] proc macros |
glam |
Encode/Decode for glam::Vec2/3/4, Quat, Mat4 |
Wire format (ZRC)
Tag-free, little-endian, tightly packed. No padding, no alignment waste.
| Type | Wire size |
|---|---|
u8 / i8 |
1 byte |
u16 / i16 |
2 bytes |
u32 / i32 / f32 |
4 bytes |
u64 / i64 / f64 |
8 bytes |
bool |
1 byte (0x00 / 0x01) |
char |
4 bytes (Unicode scalar as u32) |
[T; N] |
N * size_of(T) — no length prefix |
Vec<T> |
u32 element count + elements |
String / &str |
u32 byte length + UTF-8 bytes |
Option<T> |
1 tag byte + optional payload |
enum |
u32 variant index + payload |
struct |
fields in declaration order |
Field order is the contract. Adding or reordering fields is a breaking change.
Field attributes (v0.2.0)
Adapter pattern
For types, you don't own:
use Adapter;
;
Zero-copy reads
Borrow &str and &[u8] straight from the source buffer:
use ;
Workspace
zerec/
├── zerec/ # core library
└── zerec-derive/ # proc-macro crate (used via feature = "derive")
License
Licensed under either of Apache License 2.0 or MIT License at your option.