| Crates.io | sbdb |
| lib.rs | sbdb |
| version | 0.2.0 |
| created_at | 2025-11-07 02:34:02.353727+00 |
| updated_at | 2025-11-10 12:42:09.125027+00 |
| description | helping out your filesystem |
| homepage | |
| repository | https://github.com/wilgaboury/sbdb |
| max_upload_size | |
| id | 1921047 |
| size | 53,474 |
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.
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(())
}