pub struct BlockHeight(/* private fields */);Expand description
A block height (equivalently: consensus slot / report round), in blocks.
Implementations§
Source§impl BlockHeight
impl BlockHeight
Sourcepub const BORSH_SERIALIZED_SIZE: usize
pub const BORSH_SERIALIZED_SIZE: usize
The size of a borsh-serialized BlockHeight (identical to u64).
Sourcepub const fn to_le_bytes(self) -> [u8; 8]
pub const fn to_le_bytes(self) -> [u8; 8]
Returns the height as little-endian bytes.
Sourcepub const fn from_le_bytes(bytes: [u8; 8]) -> Self
pub const fn from_le_bytes(bytes: [u8; 8]) -> Self
Constructs from little-endian height bytes.
Sourcepub const fn saturating_add(self, n: u64) -> Self
pub const fn saturating_add(self, n: u64) -> Self
Returns the height n blocks later, saturating at BlockHeight::MAX.
Sourcepub const fn saturating_sub(self, n: u64) -> Self
pub const fn saturating_sub(self, n: u64) -> Self
Returns the height n blocks earlier, saturating at BlockHeight::ZERO.
Trait Implementations§
Source§impl BorshDeserialize for BlockHeight
impl BorshDeserialize for BlockHeight
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Deserializes this instance from a given slice of bytes.
Updates the buffer to point at the remaining bytes.
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
Deserialize this instance from a slice of bytes.
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for BlockHeight
impl BorshSerialize for BlockHeight
Source§impl Clone for BlockHeight
impl Clone for BlockHeight
impl Copy for BlockHeight
Source§impl Debug for BlockHeight
impl Debug for BlockHeight
Source§impl Default for BlockHeight
impl Default for BlockHeight
Source§impl<'de> Deserialize<'de> for BlockHeight
impl<'de> Deserialize<'de> for BlockHeight
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for BlockHeight
impl Display for BlockHeight
impl Eq for BlockHeight
Source§impl FromStr for BlockHeight
impl FromStr for BlockHeight
Source§impl Hash for BlockHeight
impl Hash for BlockHeight
Source§impl Ord for BlockHeight
impl Ord for BlockHeight
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for BlockHeight
impl PartialEq for BlockHeight
Source§impl PartialOrd for BlockHeight
impl PartialOrd for BlockHeight
Source§impl Serialize for BlockHeight
impl Serialize for BlockHeight
impl StructuralPartialEq for BlockHeight
Auto Trait Implementations§
impl Freeze for BlockHeight
impl RefUnwindSafe for BlockHeight
impl Send for BlockHeight
impl Sync for BlockHeight
impl Unpin for BlockHeight
impl UnsafeUnpin for BlockHeight
impl UnwindSafe for BlockHeight
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> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.