sdec
Snapshot Delta Encoding Codec — A transport-agnostic, bit-packed snapshot + delta codec for realtime state synchronization.
Overview
sdec provides a high-performance codec for replicating game state over the network. It focuses on:
- Bit-packed encoding — Minimize bandwidth with bit-level precision
- Delta compression — Send only what changed since the last acknowledged state
- Quantization — Configurable precision for position, rotation, and other numeric fields
- Correctness first — Bounded decoding, no panics, explicit error handling
- Engine agnostic — Bytes in, bytes out. No assumptions about ECS or networking stack
Status
🚧 Work in Progress — Currently implementing the initial core release (codec + stable wire format).
See ARCHITECTURE.md for design details and WIRE_FORMAT.md for the binary protocol specification.
Workspace Structure
| Crate | Description |
|---|---|
bitstream |
Low-level bit packing primitives (BitWriter, BitReader) |
wire |
Wire format: packet headers, section framing, limits |
schema |
Replication schema model and field codecs |
codec |
Snapshot/delta encoding and decoding |
tools |
Introspection and debugging utilities |
simbench |
Scenario generation and benchmarking |
Quick Start
use ;
use ;
let component = new
.field;
let schema = new.unwrap;
let baseline = Snapshot ;
let mut buf = ;
let _full_len = encode_full_snapshot
.unwrap;
let delta_len = encode_delta_snapshot
.unwrap;
let applied = apply_delta_snapshot
.unwrap;
Tools
The sdec-tools CLI provides packet inspection and decoding:
Schema JSON is available via the optional serde feature on the schema crate.
Demo Simulation
Generate deterministic captures and a summary report:
This writes schema.json, full_*.bin, delta_*.bin, and summary.json to the output directory.
Simbench Harness
Run a deterministic benchmark and emit summary.json:
Building
# Build all crates
# Run tests
# Run clippy
# Format code
Design Goals
- Correctness and safety — Bounded decoding, no panics, no OOM amplification
- Engine agnostic — No dependency on specific game engines or networking stacks
- Pragmatic performance — Zero steady-state allocations, competitive wire efficiency
- Evolvable format — Versioned wire protocol with room for extensions
- First-class tooling — Inspection and debugging tools are part of the product
Non-Goals (for now)
- Transport layer (UDP, QUIC, etc.)
- Interest management / relevancy filtering
- Client prediction / server reconciliation
- Encryption / authentication
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
Contributions are welcome! Please read the architecture docs before submitting PRs.
Every PR should:
- Add/extend tests proportional to changes
- Pass
cargo clippywith no warnings - Pass
cargo fmt --check - Maintain the correctness invariants documented in ARCHITECTURE.md