pub struct SecTrieDBMut<'db, L>where
    L: TrieLayout,{ /* private fields */ }
Expand description

A mutable Trie implementation which hashes keys and uses a generic HashDB backing database.

Use it as a Trie or TrieMut trait object. You can use raw() to get the backing TrieDBMut object.

Implementations§

source§

impl<'db, L> SecTrieDBMut<'db, L>where L: TrieLayout,

source

pub fn new( db: &'db mut dyn HashDB<L::Hash, DBValue>, root: &'db mut TrieHash<L> ) -> Self

Create a new trie with the backing database db and empty root Initialize to the state entailed by the genesis block. This guarantees the trie is built correctly.

source

pub fn from_existing( db: &'db mut dyn HashDB<L::Hash, DBValue>, root: &'db mut TrieHash<L> ) -> Self

Create a new trie with the backing database db and root.

source

pub fn db(&self) -> &dyn HashDB<L::Hash, DBValue>

Get the backing database.

source

pub fn db_mut(&mut self) -> &mut dyn HashDB<L::Hash, DBValue>

Get the backing database.

Trait Implementations§

source§

impl<'db, L> TrieMut<L> for SecTrieDBMut<'db, L>where L: TrieLayout,

source§

fn root(&mut self) -> &TrieHash<L>

Return the root of the trie.
source§

fn is_empty(&self) -> bool

Is the trie empty?
source§

fn contains(&self, key: &[u8]) -> Result<bool, TrieHash<L>, CError<L>>

Does the trie contain a given key?
source§

fn get<'a, 'key>( &'a self, key: &'key [u8] ) -> Result<Option<DBValue>, TrieHash<L>, CError<L>>where 'a: 'key,

What is the value of the given key in this trie?
source§

fn insert( &mut self, key: &[u8], value: &[u8] ) -> Result<Option<Value<L>>, TrieHash<L>, CError<L>>

Insert a key/value pair into the trie. An empty value is equivalent to removing key from the trie. Returns the old value associated with this key, if it existed.
source§

fn remove( &mut self, key: &[u8] ) -> Result<Option<Value<L>>, TrieHash<L>, CError<L>>

Remove a key from the trie. Equivalent to making it equal to the empty value. Returns the old value associated with this key, if it existed.

Auto Trait Implementations§

§

impl<'db, L> !RefUnwindSafe for SecTrieDBMut<'db, L>

§

impl<'db, L> !Send for SecTrieDBMut<'db, L>

§

impl<'db, L> !Sync for SecTrieDBMut<'db, L>

§

impl<'db, L> Unpin for SecTrieDBMut<'db, L>where <<L as TrieLayout>::Hash as Hasher>::Out: Unpin,

§

impl<'db, L> !UnwindSafe for SecTrieDBMut<'db, L>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.