Skip to main content

Crate peat_lite

Crate peat_lite 

Source
Expand description

§peat-lite

Lightweight CRDT primitives for resource-constrained Peat nodes.

This crate provides bounded, no_std-compatible data structures suitable for devices with limited memory (256KB RAM budget), such as:

  • WearTAK on Samsung watches
  • ESP32 sensor nodes
  • LoRa mesh devices

§Features

  • std (default): Enables standard library support
  • android: Enables UniFFI bindings for Android/Kotlin
  • Disable default features for no_std: --no-default-features

§Primitives

TypePurposeMemory
NodeId32-bit node identifier4 bytes
CannedMessagePredefined message codes1 byte
CannedMessageEventMessage with metadata~24 bytes
LwwRegisterLast-writer-wins registersizeof(T) + 12 bytes
GCounterGrow-only distributed counter4 bytes per node

§Example

use peat_lite::{NodeId, CannedMessage, CannedMessageEvent};

let my_node = NodeId::new(0x12345678);
let event = CannedMessageEvent::new(
    CannedMessage::Ack,
    my_node,
    Some(NodeId::new(0xDEADBEEF)),  // target
    1706234567000,  // timestamp ms
);

// Encode for transmission
let bytes = event.encode();
assert_eq!(bytes[0], 0xAF);  // CannedMessage marker

Re-exports§

pub use canned::CannedMessage;
pub use canned::CannedMessageAckEvent;
pub use canned::CannedMessageEvent;
pub use canned::CannedMessageStore;
pub use canned::MAX_CANNED_ACKS;
pub use counter::GCounter;
pub use lww::LwwRegister;
pub use node_id::NodeId;
pub use wire::WireError;
pub use wire::CANNED_ACK_EVENT_MAX_SIZE;
pub use wire::CANNED_MESSAGE_MARKER;
pub use wire::CANNED_MESSAGE_SIGNED_SIZE;
pub use wire::CANNED_MESSAGE_UNSIGNED_SIZE;
pub use wire::SIGNATURE_SIZE;
pub use protocol::ota;
pub use protocol::append_ttl;
pub use protocol::decode_header;
pub use protocol::default_ttl_for_crdt;
pub use protocol::encode_header;
pub use protocol::strip_ttl;
pub use protocol::CrdtType;
pub use protocol::Header;
pub use protocol::MessageError;
pub use protocol::MessageType;
pub use protocol::NodeCapabilities;
pub use protocol::constants::*;

Modules§

canned
Canned (predefined) message types for resource-constrained devices.
counter
Grow-only Counter (G-Counter) CRDT.
lww
Last-Writer-Wins Register CRDT.
node_id
Node identifier type.
protocol
Peat-Lite Wire Protocol
wire
Wire format constants and error types.