Module adaptor

Source
Expand description

Storage adaptor module providing the StorageAdaptor trait and blanket implementation of BarkPersister for any type implementing StorageAdaptor.

This module provides an optimized single-table storage abstraction that can be efficiently implemented on various backends (SQLite, Postgres, MongoDB, Firebase, in-memory, etc.).

The design uses structured keys:

  • Primary key (pk): Unique identifier for each record
  • Partition key: Groups related records for efficient querying
  • Sort key: Enables ordered iteration and range queries

§Example


// Create an in-memory storage adaptor
let mut storage = MemoryStorageAdaptor::new();

// Store a record sorted by a numeric field (ascending)
let record = Record {
    partition: 0,
    pk: "item:1".into(),
    sort_key: Some(SortKey::u32_asc(42)),
    data: b"hello world".to_vec(),
};
storage.put(record).await?;

// Query with efficient index scan
let query = Query::new(0).limit(10);
let records = storage.query(query).await?;

Modules§

filestore
Simple file-based storage for testing, built on top of the memory storage adaptor.
memory
In-memory implementation of the StorageAdaptor trait.
partition

Structs§

Query
Query specification for retrieving records from a partition.
Record
A storage record with structured keys.
SortKey
Opaque sort key encoded as bytes for lexicographic comparison.
StorageAdaptorWrapper

Traits§

StorageAdaptor
Storage adaptor trait for persistence backends.