[][src]Struct tinkv::Store

pub struct Store { /* fields omitted */ }

The Store stores key/value pairs.

Key/value pairs are persisted in data files.

Implementations

impl Store[src]

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>[src]

Initialize key value store with the given path. If the given path not found, a new one will be created.

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

Save key & value pair to database.

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

Remove key value from database.

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

Get key value from database.

pub fn compact(&mut self) -> Result<()>[src]

Clear stale entries from data files and reclaim disk space.

pub fn stats(&self) -> &Stats[src]

Return current stats of datastore.

pub fn keys(&self) -> impl Iterator<Item = &Vec<u8>>[src]

Return all keys in datastore.

pub fn len(&self) -> u64[src]

Return total number of keys in datastore.

pub fn is_empty(&self) -> bool[src]

Check datastore is empty or not.

pub fn contains_key(&self, key: &[u8]) -> bool[src]

Return true if datastore contains the given key.

pub fn for_each<F>(&mut self, f: &mut F) -> Result<()> where
    F: FnMut(&[u8], &[u8]) -> Result<bool>, 
[src]

Iterate all keys in datastore and call function f for each entry.

If function f returns an Err, it stops iteration and propgates the Err to the caller.

You can continue iteration manually by returning Ok(true), or stop iteration by returning Ok(false).

pub fn sync(&mut self) -> Result<()>[src]

Force flushing any pending writes to disk.

pub fn close(&mut self) -> Result<()>[src]

Close a tinkv data store, flush all pending writes to disk.

Trait Implementations

impl Debug for Store[src]

impl Drop for Store[src]

Auto Trait Implementations

impl RefUnwindSafe for Store

impl Send for Store

impl Sync for Store

impl Unpin for Store

impl UnwindSafe for Store

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.