Struct trie_db::FatDBMut[][src]

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

A mutable Trie implementation which hashes keys and uses a generic HashDB backing database. Additionaly it stores inserted hash-key mappings for later retrieval.

Use it as a Trie or TrieMut trait object.

Implementations

impl<'db, L> FatDBMut<'db, L> where
    L: TrieLayout
[src]

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

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

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

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

Returns an error if root does not exist.

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

Get the backing database.

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

Get the backing database.

Trait Implementations

impl<'db, L> TrieMut<L> for FatDBMut<'db, L> where
    L: TrieLayout
[src]

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

Return the root of the trie.

fn is_empty(&self) -> bool[src]

Is the trie empty?

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

Does the trie contain a given key?

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

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

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

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. Read more

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

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. Read more

Auto Trait Implementations

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

impl<'db, L> Send for FatDBMut<'db, L>

impl<'db, L> Sync for FatDBMut<'db, L>

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

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.