Crate rustlite

Crate rustlite 

Source
Expand description

§RustLite

A lightweight, high-performance embedded database written in Rust with ACID guarantees.

§Quick Start

use rustlite::Database;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a persistent database (data survives restarts)
    let db = Database::open("./my_database")?;

    // Insert data
    db.put(b"user:1:name", b"Alice")?;
    db.put(b"user:1:email", b"alice@example.com")?;

    // Retrieve data
    if let Some(name) = db.get(b"user:1:name")? {
        println!("Name: {}", String::from_utf8_lossy(&name));
    }

    // Delete data
    db.delete(b"user:1:email")?;

    // Data is automatically persisted to disk
    Ok(())
}

§Database Modes

use rustlite::Database;

// Persistent database (recommended for production)
let persistent_db = Database::open("./data")?;

// In-memory database (fast, but data lost on exit)
let memory_db = Database::in_memory()?;

§Indexing (v0.3.0+)

use rustlite::{Database, IndexType};

let db = Database::in_memory()?;

// Create indexes
db.create_index("users_by_name", IndexType::BTree)?;
db.create_index("sessions", IndexType::Hash)?;

// Use indexes for fast lookups
db.index_insert("users_by_name", b"alice", 100)?;
db.index_insert("users_by_name", b"bob", 101)?;

let results = db.index_find("users_by_name", b"alice")?;

§Features

  • v0.1.0: In-memory key-value store with thread-safe concurrent access
  • v0.2.0: Persistent storage with WAL, SSTable, and crash recovery
  • v0.3.0: B-Tree and Hash indexing for fast lookups
  • v0.4.0 (planned): SQL-like query engine
  • v1.0.0 (planned): Production-ready with full ACID guarantees

See ROADMAP.md for details.

Modules§

logging
Logging configuration for RustLite

Structs§

BTreeIndex
B-Tree based index for ordered key lookups and range queries.
Column
Column metadata
CompactionConfig
Compaction configuration
CompactionStats
Statistics for compaction
CompactionWorker
Compaction worker
Database
The main database handle.
ExecutionContext
Query execution context
Executor
Query executor
HashIndex
Hash-based index for fast O(1) exact-match lookups.
IndexInfo
Information about an index.
IndexManager
Manages multiple indexes for a database.
Lexer
Lexer state
MVCCStorage
MVCC storage for versioned data
Manifest
Manifest manager - tracks database state
Memtable
Memtable - an in-memory sorted write buffer
Parser
Parser for SQL-like queries
PhysicalPlan
Physical query plan
Planner
Query planner
Query
A complete SQL-like query
RecoveryManager
Manages WAL recovery after crash or restart
RecoveryStats
Statistics about the WAL state
Row
Query result row
SSTableEntry
A single entry in an SSTable
SSTableMeta
SSTable metadata (in-memory representation)
SSTableReader
SSTable reader - reads from existing SSTable files
SSTableWriter
SSTable writer - creates new SSTable files
SnapshotConfig
Snapshot configuration
SnapshotFile
File included in a snapshot
SnapshotManager
Snapshot manager
SnapshotMeta
Snapshot metadata
StorageConfig
Storage engine configuration
StorageEngine
Storage engine manager
StorageStats
Storage statistics
Transaction
A database transaction with MVCC support
TransactionManager
Transaction Manager for MVCC
VersionChain
MVCC version chain for a key
VersionedValue
A versioned value in MVCC
WalConfig
WAL configuration options
WalManager
WAL manager coordinates log writing and recovery
WalReader
WAL reader for reading records from log segments
WalRecord
A WAL record

Enums§

Error
The main error type for RustLite operations.
IndexType
Index type enumeration
IsolationLevel
Transaction isolation levels
MemtableEntry
Entry value in the memtable - can be a value or a tombstone (deletion marker)
SnapshotType
Type of snapshot
SyncMode
Sync mode for WAL writes
Value
Value types in query results

Constants§

VERSION

Traits§

Index
Index trait defining the common interface for all index types

Type Aliases§

Result
A specialized Result type for RustLite operations.
Timestamp
Timestamp for MVCC versioning
TransactionId
Transaction ID (monotonically increasing)