Crate hmdb

source · []
Expand description

hmdb

An embedded database with the following properties:

  • Read Optimized
  • Persistent
  • Transactional
  • In-Memory
  • Key Value Store
  • Schema defined and enforced in Rust

Defining your schema


hmdb::schema! {
    SchemaName {
        table1_name: <u8, String>,
        table2_name: <String, u64>
    }
}

Reading your db file

let db = SchemaName::init("db_dir").unwrap();

Using your tables

db.table1_name.insert(5, "test".to_string()).unwrap();
let val = db.table1_name.get(5).unwrap().unwrap();

assert_eq(5, val);

Creating a transaction

 db.transaction(|tx| {
     let mut num = tx.table2_name.get(&"test".to_string()).unwrap();
     num += 1;
     tx.table2_name.insert("test".to_string(), num).unwrap();
 }).unwrap();

Modules

Macros

Traits