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§
- BTree
Index - B-Tree based index for ordered key lookups and range queries.
- Column
- Column metadata
- Compaction
Config - Compaction configuration
- Compaction
Stats - Statistics for compaction
- Compaction
Worker - Compaction worker
- Database
- The main database handle.
- Execution
Context - Query execution context
- Executor
- Query executor
- Hash
Index - Hash-based index for fast O(1) exact-match lookups.
- Index
Info - Information about an index.
- Index
Manager - Manages multiple indexes for a database.
- Lexer
- Lexer state
- MVCC
Storage - 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
- Physical
Plan - Physical query plan
- Planner
- Query planner
- Query
- A complete SQL-like query
- Recovery
Manager - Manages WAL recovery after crash or restart
- Recovery
Stats - Statistics about the WAL state
- Row
- Query result row
- SSTable
Entry - A single entry in an SSTable
- SSTable
Meta - SSTable metadata (in-memory representation)
- SSTable
Reader - SSTable reader - reads from existing SSTable files
- SSTable
Writer - SSTable writer - creates new SSTable files
- Snapshot
Config - Snapshot configuration
- Snapshot
File - File included in a snapshot
- Snapshot
Manager - Snapshot manager
- Snapshot
Meta - Snapshot metadata
- Storage
Config - Storage engine configuration
- Storage
Engine - Storage engine manager
- Storage
Stats - Storage statistics
- Transaction
- A database transaction with MVCC support
- Transaction
Manager - Transaction Manager for MVCC
- Version
Chain - MVCC version chain for a key
- Versioned
Value - 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.
- Index
Type - Index type enumeration
- Isolation
Level - Transaction isolation levels
- Memtable
Entry - Entry value in the memtable - can be a value or a tombstone (deletion marker)
- Snapshot
Type - Type of snapshot
- Sync
Mode - Sync mode for WAL writes
- Value
- Value types in query results
Constants§
Traits§
- Index
- Index trait defining the common interface for all index types
Type Aliases§
- Result
- A specialized
Resulttype for RustLite operations. - Timestamp
- Timestamp for MVCC versioning
- Transaction
Id - Transaction ID (monotonically increasing)