kv_cab

Crates.iokv_cab
lib.rskv_cab
version0.6.0
sourcesrc
created_at2017-02-14 13:54:01.905029
updated_at2017-04-23 22:16:43.438896
descriptionSimple persistent generic HashMap/Key-value store
homepagehttps://github.com/shockham/kv_cab
repositoryhttps://github.com/shockham/kv_cab
max_upload_size
id8517
size25,828
shockham (shockham)

documentation

https://docs.rs/kv_cab

README

kv_cab

crates.io version

Simple persistent generic HashMap/Key-value store, using file locking to limit writing between threads.

This is in a beta state at the moment.

Documentation

Basic usage:

extern crate kv_cab;

use kv_cab::{ KV, Value };

fn main() {
    let mut test_store = KV::<String, Value>::new("./db.cab");

    let _ = test_store.insert("key".to_string(), Value::String("value".to_string()));
    println!("{:?}", test_store.get("key".to_string()));
    let _ = test_store.remove("key".to_string());
}

Usage with user defined Key and Value types:

extern crate kv_cab;
extern crate rustc_serialize;

use kv_cab::KV;

#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash)]
enum MyKey {
    String(String),
    Int(i32),
}

#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
enum MyValue {
    String(String),
    Int(i32),
}

fn main() {
    let mut test_store = KV::<MyKey, MyValue>::new("./db.cab");

    let _ = test_store.insert(MyKey::Int(1i32), MyValue::String("value".to_string()));
    println!("{:?}", test_store.get(MyKey::Int(1i32)));
    let _ = test_store.remove(MyKey::Int(1i32));
}
Commit count: 150

cargo fmt