[−][src]Struct tinkv::Store
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(&mut 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 for_each<F>(&mut self, f: &mut F) -> Result<()> where
F: FnMut(&[u8], &[u8]) -> Result<bool>,
[src]
F: FnMut(&[u8], &[u8]) -> Result<bool>,
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,