Struct kvdb_memorydb::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
sourceimpl KeyValueDB for InMemory
impl KeyValueDB for InMemory
sourcefn get_by_prefix(&self, col: u32, prefix: &[u8]) -> Option<Box<[u8]>>
fn get_by_prefix(&self, col: u32, prefix: &[u8]) -> Option<Box<[u8]>>
Get the first value matching the given prefix.
sourcefn write(&self, transaction: DBTransaction) -> Result<()>
fn write(&self, transaction: DBTransaction) -> Result<()>
Write a transaction of changes to the backing store.
sourcefn iter<'a>(
&'a self,
col: u32
) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>
fn iter<'a>(
&'a self,
col: u32
) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>
Iterate over the data for a given column.
sourcefn iter_with_prefix<'a>(
&'a self,
col: u32,
prefix: &'a [u8]
) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>
fn iter_with_prefix<'a>(
&'a self,
col: u32,
prefix: &'a [u8]
) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>
Iterate over the data for a given column, returning all key/value pairs where the key starts with the given prefix. Read more
sourcefn restore(&self, _new_db: &str) -> Result<()>
fn restore(&self, _new_db: &str) -> Result<()>
Attempt to replace this database with a new one located at the given path.
sourcefn transaction(&self) -> DBTransaction
fn transaction(&self) -> DBTransaction
Helper to create a new transaction.
sourceimpl MallocSizeOf for InMemory
impl MallocSizeOf for InMemory
sourcefn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
If T::size_of
is a constant, consider implementing constant_size
as well. Read more
sourcefn constant_size() -> Option<usize>
fn constant_size() -> Option<usize>
Used to optimize MallocSizeOf
implementation for collections
like Vec
and HashMap
to avoid iterating over them unnecessarily.
The Self: Sized
bound is for object safety. Read more
Auto Trait Implementations
impl !RefUnwindSafe for InMemory
impl Send for InMemory
impl Sync for InMemory
impl Unpin for InMemory
impl UnwindSafe for InMemory
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> MallocSizeOfExt for T where
T: MallocSizeOf,
impl<T> MallocSizeOfExt for T where
T: MallocSizeOf,
sourcefn malloc_size_of(&self) -> usize
fn malloc_size_of(&self) -> usize
Method to launch a heapsize measurement with a fresh state. Read more