RustLite
RustLite is a lightweight, high-performance embedded database written entirely in Rust. Designed for applications that need a fast, reliable, and embeddable storage solution with ACID guarantees.
π― Vision
RustLite aims to be the go-to embedded database for Rust applications, combining:
- Performance: Zero-copy operations, memory-mapped I/O, and efficient data structures
- Reliability: Full ACID compliance with write-ahead logging and crash recovery
- Simplicity: Single-file deployment, zero configuration, intuitive API
- Safety: Memory-safe by design using Rust's type system and ownership model
β¨ Features
Current (v0.3.0)
- β Persistent storage with LSM-tree architecture
- β Write-Ahead Logging (WAL) for crash recovery
- β SSTable compaction for optimized disk usage
- β Snapshot backups for point-in-time recovery
- β B-Tree indexing for range queries and ordered lookups
- β Hash indexing for O(1) exact-match lookups
- β Thread-safe concurrent access
- β Simple, ergonomic API
Roadmap
- π v0.4: SQL-like query engine
- π v0.5: Full transaction support with MVCC
- π v1.0: Production-ready with ACID guarantees
See docs/ROADMAP.md for detailed plans.
π Quick Start
Add RustLite to your Cargo.toml:
[]
= "0.3"
Persistent Database (Recommended)
use Database;
Data Persists Across Restarts
use Database;
// First run - write data
let db = open?;
db.put?;
drop;
// Later - data is still there!
let db = open?;
assert_eq!;
In-Memory Database (For Testing)
use Database;
// Fast in-memory storage (data lost when program exits)
let db = in_memory?;
db.put?;
Indexing for Fast Lookups (v0.3.0+)
use ;
let db = in_memory?;
// Create indexes
db.create_index?; // O(1) lookups
db.create_index?; // Range queries
// Index your data
db.put?;
db.index_insert?;
db.index_insert?;
// Fast lookups
let user_ids = db.index_find?;
println!; // Output: 1
Relational Data with Foreign Keys
See examples/relational_demo.rs for a complete example showing:
- Users and Orders tables
- Foreign key relationships
- Primary and secondary indexes
- Join queries and cascade deletes
π¦ Installation
From crates.io
From source
ποΈ Architecture
RustLite is built with a modular LSM-tree architecture:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Database API β
β (rustlite crate) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββ β
β β Indexing β β Memtable β β WAL β β
β β B-Tree + β β (BTreeMap) β β (Write Log) β β
β β Hash β βββββββββββββββ βββββββββββββββββββ β
β βββββββββββββββ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β SSTable Storage + Compaction β β
β β (Sorted String Tables on Disk) β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β βββββββββββββββ β
β β Snapshot β Point-in-time backups β
β β Manager β β
β βββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Key Components:
- Indexing: B-Tree for range queries, Hash for O(1) lookups
- Memtable: In-memory sorted buffer for fast writes
- WAL: Write-ahead log for crash recovery and durability
- SSTable: Immutable on-disk sorted files
- Compaction: Background merging to reduce read amplification
- Snapshot: Point-in-time backups for disaster recovery
See docs/ARCHITECTURE.md for technical details and docs/README.md for the full documentation index.
π€ Contributing
We welcome contributions! Please see our CONTRIBUTING.md for guidelines.
Key areas where we need help:
- Query optimizer and query planner
- Performance benchmarking and optimization
- Documentation and examples
- Platform-specific optimizations
- Advanced indexing (full-text search, spatial indexes)
π Requirements
- Rust 1.70.0 or later
- Supported platforms: Linux, macOS, Windows
π§ͺ Testing
# Run all tests (126+ tests)
# Run with logging
RUST_LOG=debug
# Run examples
# Run benchmarks
π Benchmarks
Performance benchmarks will be published as the project matures. Early benchmarks show:
- Sequential writes: TBD
- Random reads: TBD
- Concurrent operations: TBD
π Security
RustLite takes security seriously. Please report any security vulnerabilities to security@rustlite.dev.
π License
This project is licensed under the Apache License, Version 2.0 (LICENSE or http://www.apache.org/licenses/LICENSE-2.0).
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in RustLite by you shall be under the terms and conditions of the Apache License, Version 2.0, without any additional terms or conditions.
π Acknowledgments
RustLite is inspired by excellent databases like SQLite, LevelDB, and RocksDB.
π Contact & Community
- GitHub: github.com/VIRTUMEM-AI-LABS/rustlite
- Crates.io: crates.io/crates/rustlite
- Documentation: docs.rs/rustlite
- Discord: Coming soon
- Website: rustlite.dev (planned)
πΊοΈ Status
Current Status: Active development (v0.3.0)
RustLite is in active development with persistent storage, WAL, and indexing capabilities. Not yet production-ready, but suitable for experimentation and development. Star the repo to follow our progress toward v1.0!
Made with β€οΈ by the RustLite community