Struct trie_db::FatDB

source ·
pub struct FatDB<'db, 'cache, L>where
    L: TrieLayout,{ /* private fields */ }
Expand description

A 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§

source§

impl<'db, 'cache, L> FatDB<'db, 'cache, L>where L: TrieLayout,

source

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

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.

source

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

Get the backing database.

Trait Implementations§

source§

impl<'db, 'cache, L> Trie<L> for FatDB<'db, 'cache, L>where L: TrieLayout,

source§

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

Return the root of the trie.
source§

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

Does the trie contain a given key?
source§

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

Returns the hash of the value for key.
source§

fn get_with<Q: Query<L::Hash>>( &self, key: &[u8], query: Q ) -> Result<Option<Q::Item>, TrieHash<L>, CError<L>>

Search for the key with the given query parameter. See the docs of the Query trait for more details.
source§

fn iter<'a>( &'a self ) -> Result<Box<dyn TrieIterator<L, Item = TrieItem<TrieHash<L>, CError<L>>> + 'a>, TrieHash<L>, CError<L>>

Returns a depth-first iterator over the elements of trie.
source§

fn key_iter<'a>( &'a self ) -> Result<Box<dyn TrieIterator<L, Item = TrieKeyItem<TrieHash<L>, CError<L>>> + 'a>, TrieHash<L>, CError<L>>

Returns a depth-first iterator over the keys of elemets of trie.
source§

fn is_empty(&self) -> bool

Is the trie empty?
source§

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

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

Auto Trait Implementations§

§

impl<'db, 'cache, L> !RefUnwindSafe for FatDB<'db, 'cache, L>

§

impl<'db, 'cache, L> !Send for FatDB<'db, 'cache, L>

§

impl<'db, 'cache, L> !Sync for FatDB<'db, 'cache, L>

§

impl<'db, 'cache, L> Unpin for FatDB<'db, 'cache, L>

§

impl<'db, 'cache, L> !UnwindSafe for FatDB<'db, 'cache, 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.