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]) -> Result<Option<DBValue>>
fn get_by_prefix(&self, col: u32, prefix: &[u8]) -> Result<Option<DBValue>>
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 = Result<DBKeyValue>> + 'a>
fn iter<'a>(
&'a self,
col: u32
) -> Box<dyn Iterator<Item = Result<DBKeyValue>> + '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 = Result<DBKeyValue>> + 'a>
fn iter_with_prefix<'a>(
&'a self,
col: u32,
prefix: &'a [u8]
) -> Box<dyn Iterator<Item = Result<DBKeyValue>> + '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 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 moresourcefn 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 moreAuto 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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> MallocSizeOfExt for Twhere
T: MallocSizeOf,
impl<T> MallocSizeOfExt for Twhere
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