lupabase

Crates.iolupabase
lib.rslupabase
version2.0.0-dev.1
created_at2025-08-13 12:07:16.318774+00
updated_at2025-11-25 10:14:53.44191+00
descriptionBlazingly fast (work-in-progress) database engine written entirely in Rust
homepage
repositoryhttps://github.com/sonicjhon1/lupabase
max_upload_size
id1793580
size147,703
Sonicj (sonicjhon1)

documentation

README

lupabase

Docs Crates.io Downloads License

Lupabase is a blazingly fast (work-in-progress) database, written entirely in Rust. It focuses on simplicity, portability with flexible storage backends.

Features

  • Multiple Database engines built-in:

  • Flexible database record:

    • DatabaseRecord: A minimal, general-purpose record type for database operations that support custom paths. Suitable record that needs to be stored at custom file paths.
    • DatabaseRecordPartitioned: A partitioned (named) record type that enables full feature support across all database operations. This includes everything supported by DatabaseRecord. Recommended ✅
  • DatabaseRecordsUtils for database records utilities:

    • Filter records by unique key
    • Detect intersecting and non-intersecting records
    • Easily extract unique identifiers
  • DatabaseTransaction for ACID-like transactions:

    • Start transactions
    • Commit stored transations
    • Rollback transactions to a previous snapshot
  • Raw database I/O with serde through DatabaseIO:

This is not

  • A standalone database server
  • A relational database

Example/Usage

use lupabase::prelude::*;
use serde::{Serialize, Deserialize};

// Setup Record
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
struct User {
    id: u32,
    name: String,
}

impl DatabaseRecordPartitioned for User {
    const PARTITION: &str = "users";
}

impl DatabaseRecord for User {
    type Unique = u32;

    fn unique_value(&self) -> Self::Unique {
        self.id
    }
}

// Create a new Database (This example uses in-memory database that is wiped on exit)
let db = memorydb::MemoryDB::new("Test");

let users = vec![
    User { id: 0, name: "Alice".into() },
    User { id: 1, name: "Bob".into() },
];

// Initialize the Database
db.try_initialize_storage::<User, _>(users.clone()).unwrap();

// Query
let users_db = db.get_all::<User>().unwrap();
assert_eq!(users_db, users);

// Initialize the Database with a custom storage path
// The ::<Vec<User>> parameter is optional if the default_record is inferable / not empty
db.try_initialize_storage_with_path::<Vec<User>>(vec![], "custom_path").unwrap();

// Query from custom storage path
db.insert_with_path(User { id: 2, name: "Lupa".into() }, "custom_path").unwrap();

let users_custom_db = db.get_all_with_path::<User>("custom_path").unwrap();
assert_eq!(users_custom_db.len(), 1);
assert_eq!(users_custom_db[0].unique_value(), 2);

// Additional helpers
use lupabase::record_utils::*;

let uniques = users_db.as_uniques();
println!("Unique IDs: {:?}", uniques);

if let Some(user) = users_db.find_by_unique(&1) {
    println!("Found user: {}", user.name);
}

Roadmap

  • Variadic / multiple path (partition) function call
  • Concurrency-safe multi-threaded transactions
  • Improved tests and docs
  • Examples

Status

This project is under active development and not yet production-ready. Although it is in active use for my own projects, you should expect breaking changes if you use this library in the current status.

License

All code in this repository is dual-licensed under either:

at your option.

Your contributions

Any contribution submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 0

cargo fmt