Struct InMemory

Source
pub struct InMemory { /* private fields */ }
Expand description

A key-value database fulfilling the KeyValueDB trait, living in memory. This is generally intended for tests and is not particularly optimized.

Trait Implementations§

Source§

impl Clone for InMemory

Source§

fn clone(&self) -> InMemory

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl KeyValueDB for InMemory

Source§

fn delete<'a>( &self, col: u32, key: &'a [u8], ) -> Pin<Box<dyn Future<Output = Result<Option<DBValue>>> + Send + 'a>>

Remove a value by key, returning the old value

Source§

fn get<'a>( &self, col: u32, key: &'a [u8], ) -> Pin<Box<dyn Future<Output = Result<Option<DBValue>>> + Send + 'a>>

Get a value by key.
Source§

fn write( &self, transaction: DBTransaction, ) -> Pin<Box<dyn Future<Output = Result<(), DBTransactionError>> + Send>>

Write a transaction of changes to the backing store.
Source§

fn iter<'a, T: 'a, F: FnMut(DBKeyValueRef<'_>) -> Result<Option<T>> + Send + Sync + 'a>( &self, col: u32, prefix: Option<&'a [u8]>, f: F, ) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'a>>

Iterate over the data for a given column. Return all key/value pairs, optionally where the key starts with the given prefix. Iterator closure returns true for more items, false to stop iteration.
Source§

fn iter_keys<'a, T: 'a, F: FnMut(DBKeyRef<'_>) -> Result<Option<T>> + Send + Sync + 'a>( &self, col: u32, prefix: Option<&'a [u8]>, f: F, ) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'a>>

Iterate over the data for a given column. Return all keys, optionally where the key starts with the given prefix. Iterator closure returns true for more items, false to stop iteration.
Source§

fn num_columns(&self) -> Result<u32>

The number of column families in the db.
Source§

fn num_keys( &self, col: u32, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send>>

The number of keys in a column (estimated).
Source§

fn restore(&self, _new_db: &str) -> Result<()>

Attempt to replace this database with a new one located at the given path.
Source§

fn transaction(&self) -> DBTransaction

Helper to create a new transaction.
Source§

fn io_stats(&self, _kind: Kind) -> IoStats

Query statistics. Read more
Source§

fn has_key<'a>( &self, col: u32, key: &'a [u8], ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a>>

Check for the existence of a value by key.
Source§

fn has_prefix<'a>( &self, col: u32, prefix: &'a [u8], ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a>>

Check for the existence of a value by prefix.
Source§

fn first_with_prefix<'a>( &self, col: u32, prefix: &'a [u8], ) -> Pin<Box<dyn Future<Output = Result<Option<(Vec<u8>, Vec<u8>)>, Error>> + Send + 'a>>

Get the first value matching the given prefix.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.