Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

predsync

CI Crates.io PyPI

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/.

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.0rc4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for predsync 0.1.0rc4
File Size Uploaded Provenance Actions
predsync-0.1.0rc4.tar.gz 115.7 kB Without provenance Details for predsync-0.1.0rc4.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for predsync 0.1.0rc4
File Interpreter ABI Platform Actions
predsync-0.1.0rc4-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.0rc4-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
predsync-0.1.0rc4-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for predsync-0.1.0rc4-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Total release size: 1.1 MB

Release files / predsync-0.1.0rc4.tar.gz

Download URL predsync-0.1.0rc4.tar.gz
Size 115.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6be8e86323aafae6f6993d9e6a5b3940620b086a032d6ad2a44a310b7fa345f2
BLAKE2b-256 checksum
How to use checksums
72a72668e1f723f0932e92b74d3971401323461367d00e2e14c1ab5d2984c5be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / predsync-0.1.0rc4-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL predsync-0.1.0rc4-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
6f15ad2abf3e67579f6f5d57cdc6299ffdeb1318d1d955dcca4b997c28c64dd2
BLAKE2b-256 checksum
How to use checksums
fe2024cc55e9d1b1e2e7a4deefdb4d97a930466fd101a598a0658307b3c8acd0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / predsync-0.1.0rc4-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL predsync-0.1.0rc4-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
90977754f06227de80a1c54c6215bd56f2b3be5789fd31a61aa7b58f2d5ff59b
BLAKE2b-256 checksum
How to use checksums
23bec4216b0a5c77c73da5480a54bb594cb66febb07db2fb191b7e4f2474dbd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Security for predsync 0.1.0rc4

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page