Struct trie_db::Lookup

source ·
pub struct Lookup<'a, 'cache, L: TrieLayout, Q: Query<L::Hash>> {
    pub db: &'a dyn HashDBRef<L::Hash, DBValue>,
    pub query: Q,
    pub hash: TrieHash<L>,
    pub cache: Option<&'cache mut dyn TrieCache<L::Codec>>,
    pub recorder: Option<&'cache mut dyn TrieRecorder<TrieHash<L>>>,
}
Expand description

Trie lookup helper object.

Fields§

§db: &'a dyn HashDBRef<L::Hash, DBValue>

database to query from.

§query: Q

Query object to record nodes and transform data.

§hash: TrieHash<L>

Hash to start at

§cache: Option<&'cache mut dyn TrieCache<L::Codec>>

Optional cache that should be used to speed up the lookup.

§recorder: Option<&'cache mut dyn TrieRecorder<TrieHash<L>>>

Optional recorder that will be called to record all trie accesses.

Implementations§

source§

impl<'a, 'cache, L, Q> Lookup<'a, 'cache, L, Q>
where L: TrieLayout, Q: Query<L::Hash>,

source

pub fn lookup_first_descendant( self, full_key: &[u8], nibble_key: NibbleSlice<'_>, ) -> Result<Option<MerkleValue<TrieHash<L>>>, TrieHash<L>, CError<L>>

Look up the merkle value (hash) of the node that is the closest descendant for the provided key.

When the provided key leads to a node, then the merkle value (hash) of that node is returned. However, if the key does not lead to a node, then the merkle value of the closest descendant is returned. None if no such descendant exists.

source

pub fn look_up( self, full_key: &[u8], nibble_key: NibbleSlice<'_>, ) -> Result<Option<Q::Item>, TrieHash<L>, CError<L>>

Look up the given nibble_key.

If the value is found, it will be passed to the given function to decode or copy.

The given full_key should be the full key to the data that is requested. This will be used when there is a cache to potentially speed up the lookup.

source

pub fn look_up_hash( self, full_key: &[u8], nibble_key: NibbleSlice<'_>, ) -> Result<Option<TrieHash<L>>, TrieHash<L>, CError<L>>

Look up the value hash for the given nibble_key.

The given full_key should be the full key to the data that is requested. This will be used when there is a cache to potentially speed up the lookup.

Auto Trait Implementations§

§

impl<'a, 'cache, L, Q> Freeze for Lookup<'a, 'cache, L, Q>
where Q: Freeze, <<L as TrieLayout>::Hash as Hasher>::Out: Freeze,

§

impl<'a, 'cache, L, Q> !RefUnwindSafe for Lookup<'a, 'cache, L, Q>

§

impl<'a, 'cache, L, Q> !Send for Lookup<'a, 'cache, L, Q>

§

impl<'a, 'cache, L, Q> !Sync for Lookup<'a, 'cache, L, Q>

§

impl<'a, 'cache, L, Q> Unpin for Lookup<'a, 'cache, L, Q>
where Q: Unpin, <<L as TrieLayout>::Hash as Hasher>::Out: Unpin,

§

impl<'a, 'cache, L, Q> !UnwindSafe for Lookup<'a, 'cache, L, Q>

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.