Module microkv::kv

source ·
Expand description

Defines the foundational structure and API for the key-value store implementation. The kv module should be used to spin up localized instances of the key-value store.

Features

  • Database interaction operations, with sorted-key iteration possible
  • Serialization to persistent storage
  • Symmetric authenticated cryptography
  • Mutual exclusion with RWlocks and mutexes
  • Secure memory wiping

Example

use microkv::MicroKV;

let kv: MicroKV = MicroKV::new("example").with_pwd_clear("p@ssw0rd".to_string());

// put
let value = 123;
kv.put("keyname", &value);

// get
let res: i32 = kv.get_unwrap("keyname").expect("cannot retrieve value");
println!("{}", res);

// delete
kv.delete("keyname").expect("cannot delete key");

width namespace

use microkv::MicroKV;

let kv: MicroKV = MicroKV::new("example").with_pwd_clear("p@ssw0rd".to_string());
let namespace_custom = kv.namespace("custom");

// put
let value = 123;
namespace_custom.put("keyname", &value);

// get
let res: i32 = namespace_custom.get_unwrap("keyname").expect("cannot retrieve value");
println!("{}", res);

// delete
namespace_custom.delete("keyname").expect("cannot delete key");

Structs

Defines the main interface structure to represent the most recent state of the data store.