sbdb

Crates.iosbdb
lib.rssbdb
version0.2.0
created_at2025-11-07 02:34:02.353727+00
updated_at2025-11-10 12:42:09.125027+00
descriptionhelping out your filesystem
homepage
repositoryhttps://github.com/wilgaboury/sbdb
max_upload_size
id1921047
size53,474
Wil Gaboury (wilgaboury)

documentation

README

SubsidiaDB

Build Status codecov Casual Maintenance Intended

A transactional, concurrent, embedded database that utilyzes the filesystem as it's storage engine.

If you are looking for a explination of how SubsidiaDB works, try reading the included article: Turning the Filesystem into a Database.

Documentation, examples, and more thorough testing are a WIP.

Example

fn main() -> anyhow::Result<()> {
    let db = Client::new("/my/db/path")?;

    {
        let gaurd = db.read_dir(path!("some" | "dir"))?;
        let metadata = fs::metadata(gaurd.path).context("could not get metadata")?;
    }

    {
        let gaurd = db.write_dir(path!("some" | "dir"))?;
        let cp = gaurd.cp()?;
        fs::create_dir(cp.path.join("new_dir"))?;
        File::create(cp.path.join("new_file"))?;
        cp.commit()?;
    }

    {
        let gaurd = db.write_file("test_write.txt")?;
        let cp = gaurd.cp()?;
        fs::write(&cp.path, "some content")?;
        cp.commit()?;
    }

    {
        let tx = db
            .tx()
            .read("collatz_in.txt")
            .write("collatz_out.txt")
            .begin()?;
        let n = fs::read_to_string(db.root.join("collatz_in.txt"))?
            .trim()
            .parse::<i64>()?;
        if n > 1 {
            let n = if n % 2 == 0 { n / 2 } else { 3 * n + 1 };
            let cp = tx.file_cp("collatz_out.txt")?;
            fs::write(&cp.path, n.to_string())?;
            cp.commit()?;
        }
    }

    Ok(())
}
Commit count: 0

cargo fmt