Crate crdtosphere

Crate crdtosphere 

Source
Expand description

CRDTosphere

Universal Embedded CRDTs for Distributed Coordination

CRDTosphere is a comprehensive no_std Rust library implementing Conflict-free Replicated Data Types (CRDTs) optimized for embedded systems. It provides ultra-efficient, configurable CRDT implementations for automotive, robotics, IoT, and industrial applications across multiple platforms.

§Features

  • Universal Platform Support - AURIX, STM32, ARM Cortex-M, RISC-V
  • Configurable Memory - 2KB to 1MB+ budgets with compile-time verification
  • Multi-Domain Ready - Automotive, robotics, IoT, industrial applications
  • Safety Critical - ISO 26262, IEC 61508, DO-178C compliance support
  • Ultra-Efficient - 5-100 byte CRDT instances with hardware optimizations
  • No Dynamic Allocation - Pure static allocation for deterministic behavior
  • Real-Time Guarantees - Bounded execution time (<1000 CPU cycles)

§Feature Overview

§Domain-Specific Features

  • automotive - Automotive ECU and safety-critical systems (ISO 26262, ASIL-D)
  • robotics - Robotics and autonomous systems coordination
  • iot - Internet of Things and sensor networks
  • industrial - Industrial automation and control systems

§Platform-Specific Features - Mostly mutually exclusive

  • aurix - AURIX TriCore automotive MCUs (multi-core, safety features)
  • stm32 - STM32 ARM Cortex-M MCUs (power management optimizations)
  • cortex-m - Generic ARM Cortex-M platforms (memory constrained)
  • riscv - RISC-V embedded processors (variable multi-core)

§Hardware Optimization Features

  • hardware - Enable all hardware optimizations
  • hardware-atomic - Hardware atomic operations for thread safety

§Serialization Features

  • serde - Serde serialization support (no_std compatible)

§Platform Support Matrix

FeatureAURIXSTM32Cortex-MRISC-VDefault
Memory Alignment32-byte4-byte4-byte8-byte4-byte
Max Merge Cycles500200100300150
Multi-core✅ (3 cores)✅ (variable)
Safety Features✅ ASIL-D
Power Management
Real-Time Bounds✅ (100μs)✅ (50μs)✅ (25μs)✅ (30μs)✅ (40μs)

Note: Platform features are mutually exclusive. Choose one per build.

§Platform-Specific Usage Examples

§AURIX TriCore (Automotive Safety-Critical)

[dependencies]
crdtosphere = { version = "0.1", features = ["automotive", "aurix", "hardware-atomic"] }

§STM32 (IoT/Industrial)

[dependencies]
crdtosphere = { version = "0.1", features = ["iot", "stm32", "serde"] }

§Generic Cortex-M (Robotics)

[dependencies]
crdtosphere = { version = "0.1", features = ["robotics", "cortex-m"] }

§RISC-V (Research/Custom)

[dependencies]
crdtosphere = { version = "0.1", features = ["industrial", "riscv", "hardware-atomic"] }

§Quick Start

use crdtosphere::prelude::*;

// Define memory configuration for your platform
define_memory_config! {
    name: MyPlatformConfig,
    total_memory: 32 * 1024,  // 32KB budget
    max_registers: 100,
    max_counters: 50,
    max_sets: 20,
    max_maps: 10,
    max_nodes: 32,
}

fn example() -> Result<(), CRDTError> {
    // Use configurable CRDTs
    let mut sensor_reading = LWWRegister::<i16, MyPlatformConfig>::new(1);
    sensor_reading.set(42, 1000)?; // 1000 is your timestamp here.
     
    // Automatic conflict resolution
    let other_node_reading = LWWRegister::<i16, MyPlatformConfig>::new(2);
    sensor_reading.merge(&other_node_reading)?;
    Ok(())
}

§CRDT Types Available

§Counters

  • GCounter - Grow-only counter (increment only)
  • PNCounter - Increment/decrement counter

§Registers

  • LWWRegister - Last-Writer-Wins register
  • MVRegister - Multi-Value register (concurrent writes preserved)

§Sets

  • GSet - Grow-only set (add only)
  • ORSet - Observed-Remove set (add and remove)

§Maps

  • LWWMap - Last-Writer-Wins map

Modules§

automotiveautomotive
Automotive Domain CRDTs
clock
Clock management module
configs
Configuration presets module
counters
Counter CRDT implementations
error
Error handling module for CRDTosphere
industrialindustrial
Industrial Domain CRDTs
iotiot
IoT Domain CRDTs
maps
Map CRDT implementations
memory
Memory management module for CRDTosphere
platform
Platform-specific constants and optimizations
prelude
Prelude module of CRDTosphere
registers
Register CRDT implementations
roboticsrobotics
Robotics Domain CRDTs
sets
Set CRDT implementations
traits
Core CRDT traits module

Macros§

define_memory_config
Macro to define a custom memory configuration