pub struct BlockHeight(/* private fields */);Expand description
A block height. Zero denotes the genesis block.
This type is not meant for constructing height based timelocks. It is a general purpose
blockheight abstraction. For locktimes please see locktime::absolute::Height.
This is a thin wrapper around a u32 that may take on all values of a u32.
Implementations§
Source§impl BlockHeight
impl BlockHeight
Sourcepub fn checked_sub(self, other: Self) -> Option<BlockHeightInterval>
pub fn checked_sub(self, other: Self) -> Option<BlockHeightInterval>
Attempt to subtract two BlockHeights, returning None if overflow occurred.
Sourcepub fn checked_add(self, other: BlockHeightInterval) -> Option<Self>
pub fn checked_add(self, other: BlockHeightInterval) -> Option<Self>
Attempt to add an interval to this BlockHeight, returning None if overflow occurred.
Sourcepub const fn saturating_add(self, rhs: BlockHeightInterval) -> Self
pub const fn saturating_add(self, rhs: BlockHeightInterval) -> Self
Saturating integer addition.
Computes self + rhs, saturating at BlockHeight::MAX instead of overflowing.
Sourcepub const fn saturating_sub(self, rhs: BlockHeightInterval) -> Self
pub const fn saturating_sub(self, rhs: BlockHeightInterval) -> Self
Saturating integer subtraction.
Computes self - rhs, saturating at BlockHeight::MIN instead of overflowing.
Trait Implementations§
Source§impl<'a> Add<&'a BlockHeightInterval> for &BlockHeight
impl<'a> Add<&'a BlockHeightInterval> for &BlockHeight
Source§type Output = <BlockHeight as Add<BlockHeightInterval>>::Output
type Output = <BlockHeight as Add<BlockHeightInterval>>::Output
+ operator.Source§impl Add<&BlockHeightInterval> for BlockHeight
impl Add<&BlockHeightInterval> for BlockHeight
Source§type Output = <BlockHeight as Add<BlockHeightInterval>>::Output
type Output = <BlockHeight as Add<BlockHeightInterval>>::Output
+ operator.Source§impl Add<BlockHeightInterval> for &BlockHeight
impl Add<BlockHeightInterval> for &BlockHeight
Source§type Output = <BlockHeight as Add<BlockHeightInterval>>::Output
type Output = <BlockHeight as Add<BlockHeightInterval>>::Output
+ operator.Source§impl Add<BlockHeightInterval> for BlockHeight
impl Add<BlockHeightInterval> for BlockHeight
Source§type Output = BlockHeight
type Output = BlockHeight
+ operator.Source§impl<'a> Arbitrary<'a> for BlockHeight
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for BlockHeight
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl Binary for BlockHeight
impl Binary for BlockHeight
Source§impl Clone for BlockHeight
impl Clone for BlockHeight
Source§fn clone(&self) -> BlockHeight
fn clone(&self) -> BlockHeight
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BlockHeight
impl Debug for BlockHeight
Source§impl Decodable for BlockHeight
Available on crate feature encoding only.
impl Decodable for BlockHeight
encoding only.Source§impl<'de> Deserialize<'de> for BlockHeight
Available on crate feature serde only.
impl<'de> Deserialize<'de> for BlockHeight
serde only.Source§fn deserialize<D>(d: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(d: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl Display for BlockHeight
impl Display for BlockHeight
Source§impl Encodable for BlockHeight
Available on crate feature encoding only.
impl Encodable for BlockHeight
encoding only.Source§impl From<BlockHeight> for u32
impl From<BlockHeight> for u32
Source§fn from(height: BlockHeight) -> Self
fn from(height: BlockHeight) -> Self
Source§impl From<Height> for BlockHeight
impl From<Height> for BlockHeight
Source§fn from(h: Height) -> Self
fn from(h: Height) -> Self
Converts a locktime::absolute::Height to a BlockHeight.
An absolute locktime block height has a maximum value of absolute::LOCK_TIME_THRESHOLD
minus one, while BlockHeight may take the full range of u32.
Source§impl From<u32> for BlockHeight
impl From<u32> for BlockHeight
Source§impl FromStr for BlockHeight
impl FromStr for BlockHeight
Source§impl Hash for BlockHeight
impl Hash for BlockHeight
Source§impl LowerHex for BlockHeight
impl LowerHex for BlockHeight
Source§impl Octal for BlockHeight
impl Octal for BlockHeight
Source§impl Ord for BlockHeight
impl Ord for BlockHeight
Source§fn cmp(&self, other: &BlockHeight) -> Ordering
fn cmp(&self, other: &BlockHeight) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for BlockHeight
impl PartialEq for BlockHeight
Source§impl PartialOrd for BlockHeight
impl PartialOrd for BlockHeight
Source§impl Serialize for BlockHeight
Available on crate feature serde only.
impl Serialize for BlockHeight
serde only.Source§impl<'a> Sub<&'a BlockHeight> for &BlockHeight
impl<'a> Sub<&'a BlockHeight> for &BlockHeight
Source§impl Sub<&BlockHeight> for BlockHeight
impl Sub<&BlockHeight> for BlockHeight
Source§impl<'a> Sub<&'a BlockHeightInterval> for &BlockHeight
impl<'a> Sub<&'a BlockHeightInterval> for &BlockHeight
Source§type Output = <BlockHeight as Sub<BlockHeightInterval>>::Output
type Output = <BlockHeight as Sub<BlockHeightInterval>>::Output
- operator.Source§impl Sub<&BlockHeightInterval> for BlockHeight
impl Sub<&BlockHeightInterval> for BlockHeight
Source§type Output = <BlockHeight as Sub<BlockHeightInterval>>::Output
type Output = <BlockHeight as Sub<BlockHeightInterval>>::Output
- operator.Source§impl Sub<BlockHeight> for &BlockHeight
impl Sub<BlockHeight> for &BlockHeight
Source§impl Sub<BlockHeightInterval> for &BlockHeight
impl Sub<BlockHeightInterval> for &BlockHeight
Source§type Output = <BlockHeight as Sub<BlockHeightInterval>>::Output
type Output = <BlockHeight as Sub<BlockHeightInterval>>::Output
- operator.Source§impl Sub<BlockHeightInterval> for BlockHeight
impl Sub<BlockHeightInterval> for BlockHeight
Source§type Output = BlockHeight
type Output = BlockHeight
- operator.Source§impl Sub for BlockHeight
impl Sub for BlockHeight
Source§type Output = BlockHeightInterval
type Output = BlockHeightInterval
- operator.Source§impl TryFrom<&str> for BlockHeight
impl TryFrom<&str> for BlockHeight
Source§impl TryFrom<BlockHeight> for Height
impl TryFrom<BlockHeight> for Height
Source§fn try_from(h: BlockHeight) -> Result<Self, Self::Error>
fn try_from(h: BlockHeight) -> Result<Self, Self::Error>
Converts a BlockHeight to a locktime::absolute::Height.
An absolute locktime block height has a maximum value of absolute::LOCK_TIME_THRESHOLD
minus one, while BlockHeight may take the full range of u32.
Source§type Error = ConversionError
type Error = ConversionError
Source§impl TryFrom<String> for BlockHeight
Available on crate feature alloc only.
impl TryFrom<String> for BlockHeight
alloc only.