Struct sp_database::MemDb

source ·
pub struct MemDb(/* private fields */);
Expand description

This implements Database as an in-memory hash map. commit is not atomic.

Implementations§

source§

impl MemDb

source

pub fn new() -> Self

Create a new instance

source

pub fn count(&self, col: ColumnId) -> usize

Count number of values in a column

Trait Implementations§

source§

impl<H> Database<H> for MemDb
where H: Clone + AsRef<[u8]>,

source§

fn commit(&self, transaction: Transaction<H>) -> Result<()>

Commit the transaction to the database atomically. Any further calls to get or lookup will reflect the new state.
source§

fn get(&self, col: ColumnId, key: &[u8]) -> Option<Vec<u8>>

Retrieve the value previously stored against key or None if key is not currently in the database.
source§

fn contains(&self, col: ColumnId, key: &[u8]) -> bool

Check if the value exists in the database without retrieving it.
source§

fn value_size(&self, col: ColumnId, key: &[u8]) -> Option<usize>

Check value size in the database possibly without retrieving it.
source§

fn with_get(&self, col: ColumnId, key: &[u8], f: &mut dyn FnMut(&[u8]))

Call f with the value previously stored against key. Read more
source§

fn supports_ref_counting(&self) -> bool

Check if database supports internal ref counting for state data. Read more
source§

fn sanitize_key(&self, _key: &mut Vec<u8>)

Remove a possible path-prefix from the key. Read more
source§

impl Default for MemDb

source§

fn default() -> MemDb

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Freeze for MemDb

§

impl !RefUnwindSafe for MemDb

§

impl Send for MemDb

§

impl Sync for MemDb

§

impl Unpin for MemDb

§

impl UnwindSafe for MemDb

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>,

§

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>,

§

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.