pub struct Position(/* private fields */);Expand description
Implementations§
Source§impl Position
impl Position
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 MAX_POSITION.
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 MAX_POSITION.
Sourcepub const fn saturating_sub(self, rhs: u64) -> Self
pub const fn saturating_sub(self, rhs: u64) -> Self
Return self - rhs saturating at zero.
Sourcepub const fn is_mmr_size(self) -> bool
pub const fn is_mmr_size(self) -> bool
Returns whether this is a valid MMR size.
The implementation verifies that (1) the size won’t result in overflow and (2) peaks in the MMR of the given size have strictly decreasing height, which is a necessary condition for MMR validity.
Trait Implementations§
Source§impl AddAssign<u64> for Position
Add a u64 to a position.
impl AddAssign<u64> for Position
Add a u64 to a position.
§Panics
Panics if the result overflows.
Source§fn add_assign(&mut self, rhs: u64)
fn add_assign(&mut self, rhs: u64)
Performs the
+= operation. Read moreSource§impl Ord for Position
impl Ord for Position
Source§impl PartialOrd<Position> for u64
impl PartialOrd<Position> for u64
Source§impl PartialOrd<u64> for Position
impl PartialOrd<u64> for Position
Source§impl PartialOrd for Position
impl PartialOrd for Position
Source§impl Sub<u64> for Position
Subtract a u64 from a position.
impl Sub<u64> for Position
Subtract a u64 from a position.
§Panics
Panics if the result underflows.
Source§impl SubAssign<u64> for Position
Subtract a u64 from a position.
impl SubAssign<u64> for Position
Subtract a u64 from a position.
§Panics
Panics if the result underflows.
Source§fn sub_assign(&mut self, rhs: u64)
fn sub_assign(&mut self, rhs: u64)
Performs the
-= operation. Read moreSource§impl TryFrom<Location> for Position
impl TryFrom<Location> for Position
Returns an error if loc > super::MAX_LOCATION.
§Examples
use commonware_storage::mmr::{Location, Position, MAX_LOCATION};
use core::convert::TryFrom;
let loc = Location::new(5).unwrap();
let pos = Position::try_from(loc).unwrap();
assert_eq!(pos, Position::new(8));
// Invalid locations return error
assert!(Location::new(MAX_LOCATION + 1).is_none());Source§impl TryFrom<Position> for Location
impl TryFrom<Position> for Location
impl Copy for Position
impl Eq for Position
impl StructuralPartialEq for Position
Auto Trait Implementations§
impl Freeze for Position
impl RefUnwindSafe for Position
impl Send for Position
impl Sync for Position
impl Unpin for Position
impl UnwindSafe for Position
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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 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.