pub struct Location<F: Family>(/* private fields */);Expand description
A Location is a leaf index or leaf count in a Merkle structure. This is in contrast to a Position, which is a node index or node count.
§Limits
Values up to the family’s maximum are valid (see Location::is_valid). As a 0-based leaf
index, valid indices are 0..MAX - 1. As a leaf count or exclusive range-end, the maximum
is MAX itself.
Implementations§
Source§impl<F: Family> Location<F>
impl<F: Family> Location<F>
Sourcepub const fn is_valid(self) -> bool
pub const fn is_valid(self) -> bool
Returns true iff this value is a valid leaf count (<= MAX_LEAVES).
Sourcepub const fn is_valid_index(self) -> bool
pub const fn is_valid_index(self) -> bool
Returns true iff this value is a valid 0-based leaf index (< MAX_LEAVES).
Sourcepub const fn checked_add(self, rhs: u64) -> Option<Self>
pub const fn checked_add(self, rhs: u64) -> Option<Self>
Return self + rhs returning None on overflow or if result exceeds the maximum.
Sourcepub const fn checked_sub(self, rhs: u64) -> Option<Self>
pub const fn checked_sub(self, rhs: u64) -> Option<Self>
Return self - rhs returning None on underflow.
Sourcepub const fn saturating_add(self, rhs: u64) -> Self
pub const fn saturating_add(self, rhs: u64) -> Self
Return self + rhs saturating at the maximum.
Sourcepub const fn saturating_sub(self, rhs: u64) -> Self
pub const fn saturating_sub(self, rhs: u64) -> Self
Return self - rhs saturating at zero.
Trait Implementations§
Source§impl<F: Family> Add<u64> for Location<F>
Add a location and a u64.
impl<F: Family> Add<u64> for Location<F>
Add a location and a u64.
§Panics
Panics if the result overflows.
Source§impl<F: Family> Add for Location<F>
Add two locations together.
impl<F: Family> Add for Location<F>
Add two locations together.
§Panics
Panics if the result overflows.
Source§impl<F: Family> AddAssign<u64> for Location<F>
Add a u64 to a location.
impl<F: Family> AddAssign<u64> for Location<F>
Add a u64 to a location.
§Panics
Panics if the result overflows.
Source§fn add_assign(&mut self, rhs: u64)
fn add_assign(&mut self, rhs: u64)
+= operation. Read moreSource§impl<F: Family> EncodeSize for Location<F>
impl<F: Family> EncodeSize for Location<F>
Source§fn encode_size(&self) -> usize
fn encode_size(&self) -> usize
Source§fn encode_inline_size(&self) -> usize
fn encode_inline_size(&self) -> usize
BufsMut::push
during Write::write_bufs. Used to size the working buffer for inline
writes. Override alongside Write::write_bufs for types where large
Bytes fields go via push; failing to do so will over-allocate.Source§impl<F: Family> Ord for Location<F>
impl<F: Family> Ord for Location<F>
Source§impl<F: Family> PartialOrd<Location<F>> for u64
impl<F: Family> PartialOrd<Location<F>> for u64
Source§impl<F: Family> PartialOrd<u64> for Location<F>
impl<F: Family> PartialOrd<u64> for Location<F>
Source§impl<F: Family> PartialOrd for Location<F>
impl<F: Family> PartialOrd for Location<F>
Source§impl<F: Family> Read for Location<F>
impl<F: Family> Read for Location<F>
Source§impl<F: Family> Sub<u64> for Location<F>
Subtract a u64 from a location.
impl<F: Family> Sub<u64> for Location<F>
Subtract a u64 from a location.
§Panics
Panics if the result underflows.
Source§impl<F: Family> Sub for Location<F>
Subtract two locations.
impl<F: Family> Sub for Location<F>
Subtract two locations.
§Panics
Panics if the result underflows.
Source§impl<F: Family> SubAssign<u64> for Location<F>
Subtract a u64 from a location.
impl<F: Family> SubAssign<u64> for Location<F>
Subtract a u64 from a location.
§Panics
Panics if the result underflows.
Source§fn sub_assign(&mut self, rhs: u64)
fn sub_assign(&mut self, rhs: u64)
-= operation. Read moreSource§impl<F: Family> TryFrom<Location<F>> for Position<F>
impl<F: Family> TryFrom<Location<F>> for Position<F>
Equivalently, convert a leaf count to the corresponding total node count (size).
Returns super::Error::LocationOverflow if !loc.is_valid().
Source§impl<F: Family> TryFrom<Position<F>> for Location<F>
impl<F: Family> TryFrom<Position<F>> for Location<F>
Equivalently, convert a total node count (size) to the corresponding leaf count.
Returns an error if pos exceeds the valid range or if it is neither a leaf position nor a
valid size.
Source§impl<F: Family> Write for Location<F>
impl<F: Family> Write for Location<F>
Source§fn write_bufs(&self, buf: &mut impl BufsMut)
fn write_bufs(&self, buf: &mut impl BufsMut)
BufsMut, allowing existing Bytes chunks to be
appended via BufsMut::push instead of written inline. Must encode
to the same format as Write::write. Defaults to Write::write.impl<F: Family> Copy for Location<F>
impl<F: Family> Eq for Location<F>
Auto Trait Implementations§
impl<F> Freeze for Location<F>
impl<F> RefUnwindSafe for Location<F>where
F: RefUnwindSafe,
impl<F> Send for Location<F>
impl<F> Sync for Location<F>
impl<F> Unpin for Location<F>where
F: Unpin,
impl<F> UnsafeUnpin for Location<F>
impl<F> UnwindSafe for Location<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Encode for Twhere
T: Write + EncodeSize,
impl<T> Encode for Twhere
T: Write + EncodeSize,
Source§impl<T> EncodeExt for Twhere
T: EncodeSize + Write,
impl<T> EncodeExt for Twhere
T: EncodeSize + Write,
Source§fn encode_with_pool_mut(&self, pool: &BufferPool) -> IoBufMut
fn encode_with_pool_mut(&self, pool: &BufferPool) -> IoBufMut
Source§fn encode_with_pool(&self, pool: &BufferPool) -> IoBufs
fn encode_with_pool(&self, pool: &BufferPool) -> IoBufs
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.