Skip to main content

drasi_state_store_redb/
lib.rs

1#![allow(unexpected_cfgs)]
2// Copyright 2025 The Drasi Authors.
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//     http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16//! Redb-Based State Store Provider for Drasi
17//!
18//! This crate provides a persistent state store provider using [redb](https://docs.rs/redb),
19//! an embedded key-value database written in pure Rust.
20//!
21//! # Features
22//!
23//! - **ACID Transactions**: All operations are atomic and durable
24//! - **Persistent Storage**: Data survives restarts
25//! - **Partitioned by Store ID**: Each plugin gets its own table
26//! - **Thread-Safe**: Safe for concurrent access from multiple plugins
27//! - **No External Dependencies**: Pure Rust implementation
28//!
29//! # Usage
30//!
31//! ```ignore
32//! use drasi_state_store_redb::RedbStateStoreProvider;
33//! use drasi_lib::DrasiLib;
34//! use std::sync::Arc;
35//!
36//! let state_store = RedbStateStoreProvider::new("/data/state.redb")?;
37//! let drasi = DrasiLib::builder()
38//!     .with_state_store_provider(Arc::new(state_store))
39//!     .build()
40//!     .await?;
41//! ```
42//!
43//! # Database Structure
44//!
45//! The provider creates a single redb database file with a separate table for each
46//! `store_id`. Tables are created dynamically when first accessed and remain in the
47//! database for subsequent operations.
48//!
49//! Keys and values are stored as byte arrays (`&[u8]` / `Vec<u8>`).
50
51mod provider;
52
53pub use provider::RedbStateStoreProvider;