codec/lib.rs
1//! Snapshot and delta encoding/decoding for the sdec codec.
2//!
3//! This is the main codec crate that ties together bitstream, wire, and schema
4//! to provide full snapshot and delta encoding/decoding capabilities.
5//!
6//! # Features
7//!
8//! - Full snapshot encoding/decoding
9//! - Delta encoding relative to a baseline
10//! - Baseline history management
11//! - Entity create/update/destroy operations
12//! - Per-component and per-field change masks
13//!
14//! # Design Principles
15//!
16//! - **Correctness first** - All invariants are documented and tested.
17//! - **No steady-state allocations** - Uses caller-provided buffers.
18//! - **Deterministic** - Same inputs produce same outputs.
19
20mod error;
21mod types;
22
23pub use error::{CodecError, CodecResult};
24pub use types::{EntityId, SnapshotTick};
25pub use wire::Limits;
26
27#[cfg(test)]
28mod tests {
29 use super::*;
30
31 #[test]
32 fn public_api_exports() {
33 // Verify all expected items are exported
34 let _ = SnapshotTick::new(0);
35 let _ = EntityId::new(0);
36 let _ = Limits::default();
37
38 // Error types
39 let _: CodecResult<()> = Ok(());
40 }
41
42 #[test]
43 fn snapshot_tick_usage() {
44 let tick = SnapshotTick::new(100);
45 assert_eq!(tick.raw(), 100);
46 assert!(!tick.is_zero());
47 }
48
49 #[test]
50 fn entity_id_usage() {
51 let id = EntityId::new(42);
52 assert_eq!(id.raw(), 42);
53 }
54
55 #[test]
56 fn limits_reexported() {
57 // Limits is re-exported from wire
58 let limits = Limits::default();
59 assert!(limits.max_packet_bytes > 0);
60 }
61}