Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

API reference

predsync exposes the same protocol through four surfaces:

SurfaceGenerated referenceUse it when
Rust core and compilerRust API (rustdoc)You need the alloc API, fixed-storage API, schema compiler or generated wrappers in Rust.
Python bindingsPython API (pdoc)You are writing host code in Python.
C ABIC API (Doxygen)You need a stable C interface from C, C++ or another FFI-capable language.
Generated wrappersLanguage API referencesYou want typed message structs instead of hand-built value arrays.

Build all references with pixi run docs and open docs/site/index.html. The generated directories are not checked in; they are rebuilt from source on every docs run.

Common rules

All APIs share these rules:

  • A schema is parsed once and then shared by one encoder and one decoder. The message ID is derived from the message name and is stable across sets.
  • Use one encoder per sender and one decoder per incoming stream. Frames do not carry a sender identity.
  • now_ns is a monotonic host clock used only to advance frame ticks. The decoder never reads time.
  • Decoder::feed (or its language equivalent) accepts exactly one complete frame. Transport framing is the host’s responsibility.
  • Check per-field validity before acting on a value. Predicted is bounded but is not a fresh measurement; Unknown is not a value you should trust.

Choosing a Rust path

The Rust API has three levels:

  1. Alloc API — predsync_core::Encoder and Decoder with Value and Vec. This is the default and is what the Rust quickstart uses.
  2. Fixed-storage API — the same types with with_storage, plan_into and caller-owned buffers. See Embedded and no-alloc use.
  3. Generated wrappers — predsync_compiler::Builder emits typed enums, message structs and a PredictorSet; see Generated wrappers.

The C ABI mirrors the alloc API with opaque handles and caller-owned buffers. The Python bindings mirror it with dict/list values and generated classes.

Error handling

Error kindMeaning
EncodeError / predsync.EncodeErrorWrong field count, invalid value, non-finite scalar, time not advancing, stale plan, or output buffer too small.
DecodeError / predsync.DecodeErrorFrame too short, CRC mismatch, unknown message, malformed value, or stale frame.
C statusOk, NullPointer, InvalidSchema, InvalidHandle, BufferTooSmall, InvalidValue, EncodeError, DecodeError, or Panic; a second output carries the detailed code.

A rejected frame leaves predictor state and field trust unchanged, apart from named diagnostic counters such as the CRC-failure streak.