custom_types/
custom_types.rs

1extern crate kv_cab;
2extern crate serde;
3#[macro_use]
4extern crate serde_derive;
5
6use kv_cab::KV;
7
8#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
9enum MyKey {
10    String(String),
11    Int(i32),
12}
13
14#[derive(Clone, Serialize, Deserialize, Debug)]
15enum MyValue {
16    String(String),
17    Int(i32),
18}
19
20fn main() {
21    let cab_path = "./db.cab";
22    let mut test_store = KV::<MyKey, MyValue>::new(cab_path).unwrap();
23
24    let _ = test_store.insert(MyKey::Int(1i32), MyValue::String("value".to_string()));
25    println!("{:?}", test_store.get(MyKey::Int(1i32)));
26    let _ = test_store.remove(MyKey::Int(1i32));
27
28
29    // clean up the cab
30    let _ = std::fs::remove_file(cab_path);
31}