Expand description
castor
provides content addressable storage on top of LMDB
using kv
use castor::{Config, Store, Blake2s, Txn, Token};
fn main() -> Result<(), kv::Error> {
let cfg: Config<Blake2s> = Store::config("/tmp/castor-example");
let mut store: Store<Blake2s> = Store::new(cfg)?;
let bucket: kv::Bucket<Token<Blake2s>, &str> = store.bucket(None)?;
let token = store.with_write_txn(|mut txn| {
txn.put(&bucket, "testing")
})?;
let x = store.with_read_txn(move |txn| {
let value = txn.fetch(&bucket, token)?;
Ok(String::from(value))
})?;
assert_eq!(x, "testing");
Ok(())
}
Structs§
- Castor configuration, parameterized by the digest type
- A Store holds content adressable values
- A Token is a unique identifier for a stored value
- A Txn is used to read and write from a Store
Traits§
- Hash adds the
hex
method to types that already implementDigest
to simplify the process of generating a new token
Type Aliases§
- Blake2 Tokens