Introduction
predsync is a deterministic, low-bandwidth protocol for replicating predictor
state across an uncontrolled, lossy, one-way link. It is a codec-shaped library:
your application owns the transport, scheduling and threading; predsync owns the
bytes and the receiver’s trust in each field.
The sender predicts a field from its recent history. When the prediction is close
enough to the value the receiver would see, the field is omitted. When it is not,
the field is included or refreshed. Periodic Reset frames let a receiver that
missed earlier frames recover without a back channel.
What this library provides
- A schema language that fixes field order, types, wire widths, predictors and recovery periods.
- A byte-exact encoder and decoder with no hidden global state.
- Deterministic frame bytes and predictor-state hashes across platforms.
- Alloc, fixed-storage (no-alloc) and caller-owned buffer paths in Rust.
- C bindings, Python bindings and generated typed wrappers.
- Golden vectors, differential tests, fuzz targets and a cross-architecture determinism check.
What this library does not provide
- It is not middleware: it does not choose a transport, discover peers or retry frames.
- It is not a general compressor: omission is driven by declared predictors and tolerances.
- It is not a ROS 2 layer: the ROS 2 example is only one possible host.
- It does not identify senders. Use one encoder per sender and one decoder per incoming stream.
The five guarantees
- Bound. Every delivered
Predictedvalue is within the field’s tolerance of the sender’s true value after quantisation and casting. - No silent staleness. After a gap, decode failure or startup, affected
fields are
Unknownuntil re-validated. The documented exception is losing exactly a multiple of 256 consecutive frames. - Self-stabilisation. A delivered
Resetmakes the decoder’s field state equal to the encoder’s. - Determinism. Identical inputs produce identical bytes and predictions on every supported platform.
- Containment. A rejected frame leaves decoder state unchanged, apart from the documented diagnostic counters.
See Guarantees for the precise wording and measured costs.
Reading this book
Start with a quickstart, then read the schema language and protocol chapters before choosing an API. Embedded users should also read Embedded and no-alloc use. The examples chapters show complete host programs for UDP, serial/COBS, ROS 2 and generated wrappers.
API Documentation
The generated API references are available for each language: