Skip to main content

Crate aimdb_data_contracts

Crate aimdb_data_contracts 

Source
Expand description

§AimDB Data Contracts

Trait definitions for self-describing data schemas that work identically across MCU, edge, and cloud.

This crate provides:

  • Schema types — Data structures with unique identifiers (SchemaType)
  • Streamable — Marker for types that cross serialization boundaries (Streamable)
  • Contract profiles — Configuration for runtime behavior
  • Simulation support — Generate realistic test data

§Design Philosophy

Contracts separate what data looks like (schema) from how it behaves at runtime (policies). This enables:

  • Reusable schemas across different deployment configurations
  • Type-safe data exchange between systems
  • Configurable policies without changing code

§Defining a Custom Contract

use aimdb_data_contracts::{SchemaType, Streamable};
use serde::{Serialize, Deserialize};

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct MyCustomSensor {
    pub reading: f64,
    pub timestamp: u64,
}

impl SchemaType for MyCustomSensor {
    const NAME: &'static str = "my_custom_sensor";
}

// Mark as streamable — can cross WebSocket / WASM boundaries
impl Streamable for MyCustomSensor {}

Traits§

Observable
Extract a signal value for observation.
SchemaType
Identity and metadata for a data contract.
Settable
Construct a schema instance from its primary value.
Streamable
Data contracts that can be transported across serialization boundaries.