alloy_trie::nodes

Struct BranchNodeRef

Source
pub struct BranchNodeRef<'a> {
    pub stack: &'a [RlpNode],
    pub state_mask: TrieMask,
}
Expand description

A reference to BranchNode and its state mask. NOTE: The stack may contain more items that specified in the state mask.

Fields§

§stack: &'a [RlpNode]

Reference to the collection of RLP encoded nodes. NOTE: The referenced stack might have more items than the number of children for this node. We should only ever access items starting from BranchNodeRef::first_child_index.

§state_mask: TrieMask

Reference to bitmask indicating the presence of children at the respective nibble positions.

Implementations§

Source§

impl<'a> BranchNodeRef<'a>

Source

pub const fn new(stack: &'a [RlpNode], state_mask: TrieMask) -> Self

Create a new branch node from the stack of nodes.

Source

pub fn first_child_index(&self) -> usize

Returns the stack index of the first child for this node.

§Panics

If the stack length is less than number of children specified in state mask. Means that the node is in inconsistent state.

Source

pub fn children(&self) -> impl Iterator<Item = (u8, Option<&RlpNode>)> + '_

Returns an iterator over children of the branch node.

Source

pub fn child_hashes( &self, hash_mask: TrieMask, ) -> impl Iterator<Item = B256> + '_

Given the hash mask of children, return an iterator over stack items that match the mask.

Source

pub fn rlp(&self, rlp: &mut Vec<u8>) -> RlpNode

RLP-encodes the node and returns either rlp(node) or rlp(keccak(rlp(node))).

Trait Implementations§

Source§

impl<'a> Clone for BranchNodeRef<'a>

Source§

fn clone(&self) -> BranchNodeRef<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BranchNodeRef<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Encodable for BranchNodeRef<'_>

Implementation of RLP encoding for branch node in Ethereum Merkle Patricia Trie. Encode it as a 17-element list consisting of 16 slots that correspond to each child of the node (0-f) and an additional slot for a value.

Source§

fn encode(&self, out: &mut dyn BufMut)

Encodes the type into the out buffer.
Source§

fn length(&self) -> usize

Returns the length of the encoding of this type in bytes. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for BranchNodeRef<'a>

§

impl<'a> RefUnwindSafe for BranchNodeRef<'a>

§

impl<'a> Send for BranchNodeRef<'a>

§

impl<'a> Sync for BranchNodeRef<'a>

§

impl<'a> Unpin for BranchNodeRef<'a>

§

impl<'a> UnwindSafe for BranchNodeRef<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more