predsync
predsync is a deterministic, low-bandwidth protocol for replicating predictor
state across uncontrolled, lossy, one-way links. It is a codec-shaped library:
the host owns the transport, and predsync owns the bytes and the receiver's
trust in each field.
The sender omits a field while its predictor stays within that field's declared tolerance. Includes and refreshes carry true values; periodic resets let a receiver recover without a back channel.
Features
- Byte-exact wire format with LSB-first bit packing and CRC-16/IBM-SDLC.
- Schema-driven field types, predictors, tolerances and recovery schedules.
- One encoder per sender and one decoder per incoming stream; no global state.
- Alloc and caller-provided fixed-storage APIs in Rust, including
no_std. - C ABI, Python bindings and generated typed wrappers for all three languages.
- Golden vectors, differential traces, fuzz targets and Cortex-M4 determinism checks.
Documentation
Published documentation starts at https://predsync.tgodfrey.com/.
- Library guide and protocol reference
- Rust API
- Python API
- C ABI
- Guarantees and measured costs
- Testing
Generated documentation can be built locally with pixi run docs and written
to docs/site/.
Rust quickstart
Add the facade crate with predsync = "=0.1.0" (or
predsync = { version = "=0.1.0", default-features = false, features = ["alloc"] }
on embedded hosts). It re-exports schema, core and compiler APIs and installs
the predsync CLI.
use predsync::{parse_schema, Decoder, DecoderConfig, Encoder, EncoderConfig, Slot, Value};
const SCHEMA: &str = r#"
name: telemetry
sync: { refresh: 8, reset: 32 }
fields:
- name: x
type: f64
quantise: 0.01
range: [-100.0, 100.0]
predictor: { type: linear, window: 4 }
tolerance: { abs: 0.01 }
"#;
fn main() {
let set = parse_schema(SCHEMA).unwrap().set;
let mut encoder = Encoder::new(&set, 0, EncoderConfig::default()).unwrap();
let mut decoder = Decoder::new(&set, DecoderConfig { resync_n: 1 }).unwrap();
for tick in 0..3u64 {
let values = [Value::Scalar(Slot::from_f64(1.25))];
let plan = encoder.plan(&values, tick * 1_000_000).unwrap();
let mut frame = vec![0u8; plan.len];
encoder.commit(plan, &mut frame).unwrap();
let decoded = decoder.feed(&frame).unwrap();
assert_eq!(decoded.fields[0].value, values[0]);
}
}
Python quickstart
The wheel does not bundle schema YAML. Load the schema from a file path in your project; this example uses the checked-in demo schema from a source checkout:
from pathlib import Path
import predsync
from predsync.generated import Telemetry, TelemetryMode
schema_yaml = Path("examples/generated_example/schema/telemetry.yaml").read_text()
sample = Telemetry(
x=1.25,
mode=TelemetryMode.Active,
label="nominal",
samples=[7, 8, 9],
)
encoder = predsync.Encoder(schema_yaml, message=Telemetry.message_index, tick_ns=1_000_000)
decoder = predsync.Decoder(schema_yaml, message=Telemetry.message_index, resync_n=1)
for tick in range(3):
frame, _ = encoder.encode(sample.to_values(), tick * 1_000_000)
assert Telemetry.from_values(decoder.feed(frame).values()) == sample
For a runnable host with a lossy-link self-test, real UDP loopback and Ctrl-C
statistics on predicted fields and byte savings, see
examples/python.
C and command line
The C ABI is documented in the C API guide, with a
complete program in examples/c/quickstart.c. To
validate schemas or generate a Rust wrapper module without a build.rs:
pixi run schema-check --set examples/schema_sets/alpha --set examples/schema_sets/beta
pixi run schema-build --set examples/generated_example/schema/telemetry.yaml --out src/telemetry.rs
The equivalent direct commands use
cargo run -p predsync --bin predsync -- schema_check and
... schema_build. Install the tool with cargo install predsync --locked;
see the CLI guide.
Examples
| Example | Location |
|---|---|
| Generated typed Rust wrappers | examples/generated_example (see also the book chapter) |
| UDP datagrams | examples/udp |
| Python UDP host | examples/python |
| Serial byte stream with COBS | examples/serial_cobs |
ROS 2 r2r nodes |
examples/ros2 |
| C ABI quickstart | examples/c/quickstart.c |
The long-running senders (UDP, Python UDP, serial/COBS and the ROS 2 talker) print Ctrl-C summaries with predicted fields, byte savings, percentage size reduction and message sizes.
Development
The development environment is defined by pixi.toml and pixi.lock.
pixi run test # Rust workspace tests
pixi run check # all local checks, including docs and examples
pixi run ci # check plus the 60-second fuzz stage
pixi run docs # mdBook, rustdoc, pdoc, Doxygen and link checks
pixi run examples # example builds and deterministic self-tests
See Development and release for the full task list and publishing dry runs.
Licence
MIT. See LICENSE.
Metadata
Release files for predsync 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| predsync-0.1.0.tar.gz | 115.7 kB | Without provenance | Details for predsync-0.1.0.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| predsync-0.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details for predsync-0.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
| predsync-0.1.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details for predsync-0.1.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
Total release size: 1.1 MB
Release files / predsync-0.1.0.tar.gz
| Download URL | predsync-0.1.0.tar.gz |
|---|---|
| Size | 115.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
37d52d18b2319e967be908bcaabc508339021bee721db5b05d3b8d6e4eaa30fa
|
|
BLAKE2b-256 checksum How to use checksums |
4054d00b62ebe470d2957741caf409f11f73942a0d707f43ba88b0fee6ce93b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.16.0
|
Release files / predsync-0.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | predsync-0.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 488.2 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
7fb84ddf09426718f61e15648b357e8153743be174bfc82d368c0a2ab4377fc1
|
|
BLAKE2b-256 checksum How to use checksums |
4d3a6d4e51881af12271a2e07f9033ded7eda956cdf3d9b04f8db3ab7c18e0e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.16.0
|
Release files / predsync-0.1.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | predsync-0.1.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 459.8 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
ddffb248d09ccf766ad55a1426710d1e2059b2d58ddeb6eebb7fd6760e34b429
|
|
BLAKE2b-256 checksum How to use checksums |
024349acfa328618d98248100afad8bfb548b258c2be9af73af72e9ca995add9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.16.0
|
Security for predsync 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.