Struct TrieMask

Source
pub struct TrieMask(/* private fields */);
Expand description

A struct representing a mask of 16 bits, used for Ethereum trie operations.

Masks in a trie are used to efficiently represent and manage information about the presence or absence of certain elements, such as child nodes, within a trie. Masks are usually implemented as bit vectors, where each bit represents the presence (1) or absence (0) of a corresponding element.

Implementations§

Source§

impl TrieMask

Source

pub const fn new(inner: u16) -> Self

Creates a new TrieMask from the given inner value.

Source

pub const fn get(self) -> u16

Returns the inner value of the TrieMask.

Source

pub const fn from_nibble(nibble: u8) -> Self

Creates a new TrieMask from the given nibble.

Source

pub fn is_subset_of(self, other: Self) -> bool

Returns true if the current TrieMask is a subset of other.

Source

pub const fn is_bit_set(self, index: u8) -> bool

Returns true if a given bit is set in a mask.

Source

pub const fn is_empty(self) -> bool

Returns true if the mask is empty.

Source

pub const fn count_bits(self) -> u8

Returns the number of bits set in the mask.

Source

pub const fn first_set_bit_index(self) -> Option<u8>

Returns the index of the first bit set in the mask, or None if the mask is empty.

Source

pub fn set_bit(&mut self, index: u8)

Set bit at a specified index.

Source

pub fn unset_bit(&mut self, index: u8)

Unset bit at a specified index.

Methods from Deref<Target = u16>§

1.43.0 · Source

pub const MIN: u16 = 0u16

1.43.0 · Source

pub const MAX: u16 = 65_535u16

1.53.0 · Source

pub const BITS: u32 = 16u32

Trait Implementations§

Source§

impl BitAnd for TrieMask

Source§

type Output = TrieMask

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: TrieMask) -> TrieMask

Performs the & operation. Read more
Source§

impl BitAndAssign for TrieMask

Source§

fn bitand_assign(&mut self, rhs: TrieMask)

Performs the &= operation. Read more
Source§

impl BitOr for TrieMask

Source§

type Output = TrieMask

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: TrieMask) -> TrieMask

Performs the | operation. Read more
Source§

impl BitOrAssign for TrieMask

Source§

fn bitor_assign(&mut self, rhs: TrieMask)

Performs the |= operation. Read more
Source§

impl Clone for TrieMask

Source§

fn clone(&self) -> TrieMask

Returns a duplicate 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 TrieMask

Source§

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

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

impl Default for TrieMask

Source§

fn default() -> TrieMask

Returns the “default value” for a type. Read more
Source§

impl Deref for TrieMask

Source§

type Target = u16

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl From<u16> for TrieMask

Source§

fn from(value: u16) -> Self

Converts to this type from the input type.
Source§

impl Not for TrieMask

Source§

type Output = TrieMask

The resulting type after applying the ! operator.
Source§

fn not(self) -> TrieMask

Performs the unary ! operation. Read more
Source§

impl Ord for TrieMask

Source§

fn cmp(&self, other: &TrieMask) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for TrieMask

Source§

fn eq(&self, other: &TrieMask) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for TrieMask

Source§

fn partial_cmp(&self, other: &TrieMask) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for TrieMask

Source§

impl Eq for TrieMask

Source§

impl StructuralPartialEq for TrieMask

Auto Trait Implementations§

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, dest: *mut u8)

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

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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