Struct Store

Source
pub struct Store { /* private fields */ }

Implementations§

Source§

impl Store

Source

pub fn create(dir: &str) -> Result<(), Error>

Creates a new store in a new directory.

Source

pub fn open(dir: &str, threshold: usize) -> Result<Store, Error>

Opens the store.

threshold is an upper bound on the size of unflushed data.

Source

pub fn insert(&mut self, key: &[u8], val: &[u8]) -> Result<bool, Error>

Inserts a key/value pair into the store if the key is not already present. Returns true if an insertion happened.

Source

pub fn replace(&mut self, key: &[u8], val: &[u8]) -> Result<bool, Error>

Replaces an existing key/value pair in the store. If the key is not present, does nothing and returns false.

Source

pub fn put(&mut self, key: &[u8], val: &[u8]) -> Result<(), Error>

Puts a key/value pair into the store, replacing the value if the key is already present. Compare to insert or replace.

Source

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

Removes a key/value pair from the store. Returns true if the key was present.

Source

pub fn sync(&mut self) -> Result<(), Error>

Ensures that all preceding write operations have been written to disk (if you trust your kernel and your disk).

Source

pub fn flush(&mut self) -> Result<(), Error>

Flushes any buffered write operations to disk.

Source

pub fn exists(&mut self, key: &[u8]) -> Result<bool, Error>

Returns true if a key/value pair is present, for the given key.

Source

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

Gets the value for the specified key/value pair, or None if the key does not exist.

Source

pub fn range_directed<'a>( &'a self, interval: &Interval<Vec<u8>>, direction: Direction, ) -> Result<StoreIter<'a>, Error>

Produces a store iterator for iterating the store over the given interval, in the given direction.

Source

pub fn range<'a>( &'a self, interval: &Interval<Vec<u8>>, ) -> Result<StoreIter<'a>, Error>

Creates a StoreIter for iterating forwards through the interval.

Source

pub fn range_descending<'a>( &'a self, interval: &Interval<Vec<u8>>, ) -> Result<StoreIter<'a>, Error>

Creates a StoreIter for iterating backwards through the interval.

Source

pub fn next( &self, iter: &mut StoreIter<'_>, ) -> Result<Option<(Vec<u8>, Vec<u8>)>, Error>

Produces the next key/value pair from the StoreIter. Returns None to mark the end of iteration.

Auto Trait Implementations§

§

impl Freeze for Store

§

impl RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnwindSafe for Store

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Erased for T