Struct grovedb_merk::tree::RefWalker

source ·
pub struct RefWalker<'a, S>
where S: Fetch + Sized + Clone,
{ /* private fields */ }
Expand description

Allows read-only traversal of a Tree, fetching from the given source when traversing to a pruned node. The fetched nodes are then retained in memory until they (possibly) get pruned on the next commit.

Only finalized trees may be walked (trees which have had commit called since the last update).

Implementations§

source§

impl<'a, S> RefWalker<'a, S>
where S: Fetch + Sized + Clone,

source

pub fn create_chunk( &mut self, depth: usize, grove_version: &GroveVersion, ) -> Result<Vec<Op>, Error>

Returns a chunk of a given depth from a RefWalker

source

pub fn traverse_and_build_chunk( &mut self, instructions: &[bool], depth: usize, grove_version: &GroveVersion, ) -> Result<Vec<Op>, Error>

Returns a chunk of a given depth after applying some traversal instruction to the RefWalker

source

pub fn generate_height_proof( &mut self, proof: &mut Vec<Op>, grove_version: &GroveVersion, ) -> CostResult<(), Error>

Returns the smallest amount of tree ops, that can convince a verifier of the tree height the generated subtree is of this form kv_hash /
kv_hash node_hash /
kv_hash node_hash . . .

source§

impl<'a, S> RefWalker<'a, S>
where S: Fetch + Sized + Clone,

source

pub fn new(tree: &'a mut TreeNode, source: S) -> Self

Creates a RefWalker with the given tree and source.

source

pub fn tree(&self) -> &TreeNode

Gets an immutable reference to the Tree wrapped by this RefWalker.

source

pub fn walk<V>( &mut self, left: bool, value_defined_cost_fn: Option<&V>, grove_version: &GroveVersion, ) -> CostResult<Option<RefWalker<'_, S>>, Error>

Traverses to the child on the given side (if any), fetching from the source if pruned. When fetching, the link is upgraded from Link::Reference to Link::Loaded.

Auto Trait Implementations§

§

impl<'a, S> Freeze for RefWalker<'a, S>
where S: Freeze,

§

impl<'a, S> RefUnwindSafe for RefWalker<'a, S>
where S: RefUnwindSafe,

§

impl<'a, S> Send for RefWalker<'a, S>
where S: Send,

§

impl<'a, S> Sync for RefWalker<'a, S>
where S: Sync,

§

impl<'a, S> Unpin for RefWalker<'a, S>
where S: Unpin,

§

impl<'a, S> !UnwindSafe for RefWalker<'a, S>

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> CostsExt for T

source§

fn wrap_with_cost(self, cost: OperationCost) -> CostContext<Self>
where Self: Sized,

Wraps any value into a CostContext object with provided costs.
source§

fn wrap_fn_cost( self, f: impl FnOnce(&Self) -> OperationCost, ) -> CostContext<Self>
where Self: Sized,

Wraps any value into CostContext object with costs computed using the value getting wrapped.
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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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> TryFromVersioned<U> for T
where T: TryFrom<U>,

§

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

The type returned in the event of a conversion error.
source§

fn try_from_versioned( value: U, _grove_version: &GroveVersion, ) -> Result<T, <T as TryFromVersioned<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.
source§

impl<T, U> TryIntoVersioned<U> for T
where U: TryFromVersioned<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into_versioned( self, grove_version: &GroveVersion, ) -> Result<U, <U as TryFromVersioned<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V