[][src]Struct leetup_cache::kvstore::KvStore

pub struct KvStore { /* fields omitted */ }

The KvStore stores string key/value pairs.

Key/value pairs are persisted to disk in log files. Log files are named after monotonically increasing generation numbers with a log extension name. A BTreeMap in memory stores the keys and the value locations for fast query.

use std::env::current_dir;
let mut store = KvStore::open(current_dir()?)?;
store.set("key".to_owned(), "value".to_owned())?;
let val = store.get("key".to_owne())?;
assert_eq!(val, Some("value".to_owned()));

Implementations

impl KvStore[src]

pub fn open<T: Into<PathBuf>>(path: T) -> Result<Self>[src]

Opens a KvStore with the given path.

pub fn set(&mut self, key: String, value: String) -> Result<()>[src]

Sets the value of s string key to a string.

pub fn get(&mut self, key: String) -> Result<Option<String>>[src]

Gets the string value for a given key.

pub fn remove(&mut self, key: String) -> Result<()>[src]

Removes the given key.

Auto Trait Implementations

impl RefUnwindSafe for KvStore

impl Send for KvStore

impl Sync for KvStore

impl Unpin for KvStore

impl UnwindSafe for KvStore

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.