smolheed

Crates.iosmolheed
lib.rssmolheed
version0.1.0
sourcesrc
created_at2021-11-24 15:28:31.30934
updated_at2021-11-24 15:28:31.30934
descriptionA thin wrapped on top of LMDB with minimum overhead
homepage
repositoryhttps://github.com/Kerollmops/smolheed
max_upload_size
id486879
size177,165
LV2 Maintainers (github:rustaudio:lv2-maintainers)

documentation

README

smolheed

A thin wrapped on top of LMDB with minimum overhead. It is derived from the heed crate which is more typed and a little bit more complex.

It provides you a way to store key/values in LMDB without any limit and with a minimal overhead.

Example Usage

fs::create_dir_all("target/heed.mdb")?;
let env = EnvOpenOptions::new().open("target/heed.mdb")?;

// We open the default unamed database.
// Specifying the type of the newly created database.
// Here we specify that the key is an str and the value a simple integer.
let db = env.create_database(None)?;

// We then open a write transaction and start writing into the database.
// All of those puts are type checked at compile time,
// therefore you cannot write an integer instead of a string.
let mut wtxn = env.write_txn()?;
db.put(&mut wtxn, "seven", 7_i32.to_be_bytes())?;
db.put(&mut wtxn, "zero",  0_i32.to_be_bytes())?;
db.put(&mut wtxn, "five",  5_i32.to_be_bytes())?;
db.put(&mut wtxn, "three", 3_i32.to_be_bytes())?;
wtxn.commit()?;

// We open a read transaction to check if those values are available.
// When we read we also type check at compile time.
let rtxn = env.read_txn()?;

let ret = db.get(&rtxn, "zero")?;
assert_eq!(ret, Some(&0_i32.to_be_bytes()[..]));

let ret = db.get(&rtxn, "five")?;
assert_eq!(ret, Some(&5.to_be_bytes()[..]));

You want to see more about all the possibilities? Go check out the examples.

Commit count: 267

cargo fmt