Thanks to visit codestin.com
Credit goes to lib.rs

#key-value #lmdb #aingle

bin+lib aingle-rkv

A simple, humane, typed Rust key-value store for AIngle

1 unstable release

new 0.1.0 Dec 17, 2025

#3 in #aingle

Apache-2.0

165KB
3K SLoC

AIngle Logo

aingle-rkv

Typed key-value storage with multiple backends for AIngle

Crates.io Documentation License CI Status


Overview

A simple, humane, typed key-value storage solution for Rust. This crate supports multiple backend engines with varying guarantees, optimized for use within the AIngle distributed systems framework.

Features

  • Multiple backends - LMDB for performance, SafeMode for reliability
  • Type-safe API - Strongly typed keys and values
  • Concurrent access - Multi-reader, single-writer transactions
  • Crash-safe - ACID-compliant storage with durability guarantees
  • Compact - Efficient memory-mapped I/O

Installation

[dependencies]
aingle-rkv = "0.1"

Quick Start

use rkv::{Manager, Rkv, StoreOptions, Value};
use std::path::Path;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Open or create the environment
    let path = Path::new("./my-store");
    let mut manager = Manager::singleton().write()?;
    let env = manager.get_or_create(path, Rkv::new)?;

    // Open a store
    let store = env.read()?.open_single("mystore", StoreOptions::create())?;

    // Write data
    {
        let mut writer = env.read()?.write()?;
        store.put(&mut writer, "key", &Value::Str("value"))?;
        writer.commit()?;
    }

    // Read data
    let reader = env.read()?.read()?;
    let value = store.get(&reader, "key")?;
    println!("Value: {:?}", value);

    Ok(())
}

Backend Engines

Backend Use Case Characteristics
LMDB High performance Memory-mapped, fast reads
SafeMode Reliability In-memory with sync writes
SQLite Portability Planned for future release

SafeMode Backend

For production environments requiring maximum reliability:

use rkv::{Manager, Rkv};
use rkv::backend::{SafeMode, SafeModeEnvironment};

let mut manager = Manager::<SafeModeEnvironment>::singleton().write()?;
let env = manager.get_or_create(path, Rkv::new::<SafeMode>)?;

Features Flags

Feature Description Default
db-dup-sort Multiple values per key Yes
db-int-key Integer key optimizations Yes
backtrace Error backtraces No

Build & Test

# Build
cargo build

# Run tests
cargo test

# Generate documentation
cargo doc --open

# Run examples
./run-all-examples.sh

Part of AIngle

This crate is part of the AIngle ecosystem - a Semantic DAG framework for IoT and distributed AI applications.

License

Licensed under the Apache License, Version 2.0. See LICENSE for details.


Maintained by Apilium Technologies - Tallinn, Estonia

Dependencies

~4–5.5MB
~97K SLoC