Skip to main content

Crate predsync

Crate predsync 

Source
Expand description

Public Rust API for predsync.

This is the user-facing crate. It re-exports the schema, codec and compiler crates under namespace modules and also surfaces the most common types at the root. The command-line tool is installed with cargo install predsync.

#[cfg(feature = "compiler")]
fn main() {
use predsync::{parse_schema, Decoder, DecoderConfig, Encoder, EncoderConfig, Slot, Value};

let set = parse_schema(
    "name: telemetry\nsync: { refresh: 8, reset: 32 }\nfields:\n  - name: x\n    type: f64\n    quantise: 0.01\n    range: [-100.0, 100.0]\n",
)
.unwrap()
.set;
let mut encoder = Encoder::new(&set, 0, EncoderConfig::default()).unwrap();
let mut decoder = Decoder::new(&set, DecoderConfig { resync_n: 1 }).unwrap();

let values = [Value::Scalar(Slot::from_f64(1.25))];
let plan = encoder.plan(&values, 0).unwrap();
let mut frame = vec![0u8; plan.len];
let info = encoder.commit(plan, &mut frame).unwrap();
frame.truncate(info.len);
assert_eq!(decoder.feed(&frame).unwrap().fields[0].value, values[0]);
}
#[cfg(not(feature = "compiler"))]
fn main() {}

Embedded users should disable defaults. compiler implies std, so a no_std build needs default-features = false and, if allocation is available, the alloc feature alone.

Re-exports§

pub use predsync_compiler as compiler;
pub use predsync_core as core;
pub use predsync_schema as schema;

Structs§

Builder
A build-script helper for one or more receiver schema sets.
Decoded
A fully validated output frame (allocator-backed convenience form).
Decoder
Decoder for one incoming stream; message IDs dispatch within that stream.
DecoderConfig
Decoder configuration.
EncodeInfo
Statistics and saturation flags returned by a successful commit.
Encoder
Encoder for one message of a schema set.
EncoderConfig
Encoder configuration: tick duration and the optional reset budget.
EnumDef
An enum declaration; the wire value is the variant index.
FieldOut
One decoded field and its trust state.
FieldSchema
One field of a message, in wire order.
GeneratedC
The two halves of a generated C wrapper: a C header fragment and Rust glue.
MessageSchema
One message type in a schema set.
ParsedSchema
A parsed schema set with its non-fatal warnings.
Plan
A pure encoding decision; feed it to Encoder::commit to write a frame.
PredictorRegistry
Explicit registry mapping custom predictor names to runtime factories.
PredictorSpec
Predictor configuration declared inline on a field.
SchemaSet
All messages that share one wire contract.
Slot
One scalar value: unsigned integer, sign-extended signed integer, float bits or 0/1.
StorageLayout
Storage layout for no-alloc engine.
SyncDefaults
Message-level recovery defaults.
ToleranceSpec
Tolerance bounds on the delivered value of a numeric field.
Warning
A non-fatal schema warning.

Enums§

BoundedValue
Bounded value for no-alloc encode/decode.
CodegenError
A schema construct that cannot be represented in generated output.
ConfigError
Configuration errors detected when constructing an encoder.
DecodeError
Errors returned by decoder operations.
EncodeError
Errors returned by encoding operations.
FieldType
The wire type of a field.
PredictorKind
Predictor kinds supported by the schema.
PredictorParamValue
A numeric parameter value for a custom predictor.
Presence
The two-bit state written for one predictor field.
ScalarType
The scalar types that can be carried in a Slot.
SchemaError
Every schema grammar or validation failure.
ToleranceMode
How absolute and relative bounds combine when both are present.
Validity
The trust state of one decoded field.
Value
A field value at the core alloc API boundary.
ValueRef
Borrowed value view used by core encode/decode logic.
WarningKind
Categories of schema warning.

Traits§

PredictorBuilder

Functions§

generate_c
Generate C declarations and Rust implementations for every message in set.
generate_python
Generate Python message classes for every message in set.
generate_rust
Generate one Rust source file for every message in set.
generate_rust_with_options
Generate Rust with build-time options.
parse_schema
Parse YAML into a schema set and hand it to the validator.
version_marker
Returns the facade version marker used by the workspace smoke tests.