1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use std::path::Path;
use kv;
use txn::Txn;
use token::Token;
pub struct Store(pub kv::Store);
impl Store {
pub fn config<P: AsRef<Path>>(path: P) -> kv::Config {
kv::Config::default(path)
}
pub fn new(cfg: kv::Config) -> Result<Store, kv::Error> {
Ok(Store(kv::Store::new(cfg)?))
}
pub fn read_txn<'a>(&'a self) -> Result<Txn<'a>, kv::Error> {
Ok(Txn(self.0.read_txn()?))
}
pub fn write_txn<'a>(&'a mut self) -> Result<Txn<'a>, kv::Error> {
Ok(Txn(self.0.write_txn()?))
}
pub fn bucket<'a, V: kv::Value<'a>>(&self, name: Option<&str>) -> Result<kv::Bucket<'a, Token, V>, kv::Error> {
self.0.bucket(name)
}
}