pub struct BlockHeightInterval(/* private fields */);Expand description
An unsigned block interval.
Block interval is an integer type representing a difference between the heights of two blocks.
This type is not meant for constructing relative height based timelocks. It is a general
purpose block interval abstraction. For locktimes please see [locktime::relative::NumberOfBlocks].
Implementations§
Source§impl BlockHeightInterval
impl BlockHeightInterval
Sourcepub const ZERO: BlockHeightInterval
pub const ZERO: BlockHeightInterval
Block interval 0.
Sourcepub const MIN: BlockHeightInterval = Self::ZERO
pub const MIN: BlockHeightInterval = Self::ZERO
The minimum block interval, equivalent to Self::ZERO.
Sourcepub const MAX: BlockHeightInterval
pub const MAX: BlockHeightInterval
The maximum block interval.
Sourcepub const fn from_u32(inner: u32) -> BlockHeightInterval
pub const fn from_u32(inner: u32) -> BlockHeightInterval
Constructs a new block interval from a u32.
Sourcepub fn checked_sub(
self,
other: BlockHeightInterval,
) -> Option<BlockHeightInterval>
pub fn checked_sub( self, other: BlockHeightInterval, ) -> Option<BlockHeightInterval>
Attempt to subtract two BlockHeightIntervals, returning None if overflow occurred.
Sourcepub fn checked_add(
self,
other: BlockHeightInterval,
) -> Option<BlockHeightInterval>
pub fn checked_add( self, other: BlockHeightInterval, ) -> Option<BlockHeightInterval>
Attempt to add two BlockHeightIntervals, returning None if overflow occurred.
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§fn add(
self,
rhs: &BlockHeightInterval,
) -> <&BlockHeight as Add<&'a BlockHeightInterval>>::Output
fn add( self, rhs: &BlockHeightInterval, ) -> <&BlockHeight as Add<&'a BlockHeightInterval>>::Output
+ operation. Read moreSource§impl<'a> Add<&'a BlockHeightInterval> for &BlockHeightInterval
impl<'a> Add<&'a BlockHeightInterval> for &BlockHeightInterval
Source§type Output = <BlockHeightInterval as Add>::Output
type Output = <BlockHeightInterval as Add>::Output
+ operator.Source§fn add(
self,
rhs: &BlockHeightInterval,
) -> <&BlockHeightInterval as Add<&'a BlockHeightInterval>>::Output
fn add( self, rhs: &BlockHeightInterval, ) -> <&BlockHeightInterval as Add<&'a BlockHeightInterval>>::Output
+ operation. Read moreSource§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§fn add(
self,
rhs: &BlockHeightInterval,
) -> <BlockHeight as Add<&BlockHeightInterval>>::Output
fn add( self, rhs: &BlockHeightInterval, ) -> <BlockHeight as Add<&BlockHeightInterval>>::Output
+ operation. Read moreSource§impl Add<&BlockHeightInterval> for BlockHeightInterval
impl Add<&BlockHeightInterval> for BlockHeightInterval
Source§type Output = <BlockHeightInterval as Add>::Output
type Output = <BlockHeightInterval as Add>::Output
+ operator.Source§fn add(
self,
rhs: &BlockHeightInterval,
) -> <BlockHeightInterval as Add<&BlockHeightInterval>>::Output
fn add( self, rhs: &BlockHeightInterval, ) -> <BlockHeightInterval as Add<&BlockHeightInterval>>::Output
+ operation. Read moreSource§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§fn add(
self,
rhs: BlockHeightInterval,
) -> <&BlockHeight as Add<BlockHeightInterval>>::Output
fn add( self, rhs: BlockHeightInterval, ) -> <&BlockHeight as Add<BlockHeightInterval>>::Output
+ operation. Read moreSource§impl Add<BlockHeightInterval> for &BlockHeightInterval
impl Add<BlockHeightInterval> for &BlockHeightInterval
Source§type Output = <BlockHeightInterval as Add>::Output
type Output = <BlockHeightInterval as Add>::Output
+ operator.Source§fn add(
self,
rhs: BlockHeightInterval,
) -> <&BlockHeightInterval as Add<BlockHeightInterval>>::Output
fn add( self, rhs: BlockHeightInterval, ) -> <&BlockHeightInterval as Add<BlockHeightInterval>>::Output
+ operation. Read moreSource§impl Add<BlockHeightInterval> for BlockHeight
impl Add<BlockHeightInterval> for BlockHeight
Source§type Output = BlockHeight
type Output = BlockHeight
+ operator.Source§fn add(
self,
rhs: BlockHeightInterval,
) -> <BlockHeight as Add<BlockHeightInterval>>::Output
fn add( self, rhs: BlockHeightInterval, ) -> <BlockHeight as Add<BlockHeightInterval>>::Output
+ operation. Read moreSource§impl Add for BlockHeightInterval
impl Add for BlockHeightInterval
Source§type Output = BlockHeightInterval
type Output = BlockHeightInterval
+ operator.Source§fn add(self, rhs: BlockHeightInterval) -> <BlockHeightInterval as Add>::Output
fn add(self, rhs: BlockHeightInterval) -> <BlockHeightInterval as Add>::Output
+ operation. Read moreSource§impl AddAssign<&BlockHeightInterval> for BlockHeightInterval
impl AddAssign<&BlockHeightInterval> for BlockHeightInterval
Source§fn add_assign(&mut self, rhs: &BlockHeightInterval)
fn add_assign(&mut self, rhs: &BlockHeightInterval)
+= operation. Read moreSource§impl AddAssign for BlockHeightInterval
impl AddAssign for BlockHeightInterval
Source§fn add_assign(&mut self, rhs: BlockHeightInterval)
fn add_assign(&mut self, rhs: BlockHeightInterval)
+= operation. Read moreSource§impl<'a> Arbitrary<'a> for BlockHeightInterval
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for BlockHeightInterval
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<BlockHeightInterval, Error>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<BlockHeightInterval, Error>
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 BlockHeightInterval
impl Binary for BlockHeightInterval
Source§impl Clone for BlockHeightInterval
impl Clone for BlockHeightInterval
Source§fn clone(&self) -> BlockHeightInterval
fn clone(&self) -> BlockHeightInterval
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BlockHeightInterval
impl Debug for BlockHeightInterval
Source§impl Default for BlockHeightInterval
impl Default for BlockHeightInterval
Source§fn default() -> BlockHeightInterval
fn default() -> BlockHeightInterval
Source§impl<'de> Deserialize<'de> for BlockHeightInterval
Available on crate feature serde only.
impl<'de> Deserialize<'de> for BlockHeightInterval
serde only.Source§fn deserialize<D>(
d: D,
) -> Result<BlockHeightInterval, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
d: D,
) -> Result<BlockHeightInterval, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for BlockHeightInterval
impl Display for BlockHeightInterval
Source§impl From<BlockHeightInterval> for u32
impl From<BlockHeightInterval> for u32
Source§fn from(height: BlockHeightInterval) -> u32
fn from(height: BlockHeightInterval) -> u32
Source§impl From<NumberOfBlocks> for BlockHeightInterval
impl From<NumberOfBlocks> for BlockHeightInterval
Source§fn from(h: NumberOfBlocks) -> BlockHeightInterval
fn from(h: NumberOfBlocks) -> BlockHeightInterval
Converts a [locktime::relative::NumberOfBlocks] to a BlockHeightInterval.
A relative locktime block height has a maximum value of u16::MAX where as a
BlockHeightInterval is a thin wrapper around a u32, the two types are not interchangeable.
Source§impl From<u32> for BlockHeightInterval
impl From<u32> for BlockHeightInterval
Source§fn from(inner: u32) -> BlockHeightInterval
fn from(inner: u32) -> BlockHeightInterval
Source§impl FromStr for BlockHeightInterval
impl FromStr for BlockHeightInterval
Source§type Err = ParseIntError
type Err = ParseIntError
Source§fn from_str(
s: &str,
) -> Result<BlockHeightInterval, <BlockHeightInterval as FromStr>::Err>
fn from_str( s: &str, ) -> Result<BlockHeightInterval, <BlockHeightInterval as FromStr>::Err>
s to return a value of this type. Read moreSource§impl Hash for BlockHeightInterval
impl Hash for BlockHeightInterval
Source§impl LowerHex for BlockHeightInterval
impl LowerHex for BlockHeightInterval
Source§impl Octal for BlockHeightInterval
impl Octal for BlockHeightInterval
Source§impl Ord for BlockHeightInterval
impl Ord for BlockHeightInterval
Source§fn cmp(&self, other: &BlockHeightInterval) -> Ordering
fn cmp(&self, other: &BlockHeightInterval) -> 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 BlockHeightInterval
impl PartialEq for BlockHeightInterval
Source§impl PartialOrd for BlockHeightInterval
impl PartialOrd for BlockHeightInterval
Source§impl Serialize for BlockHeightInterval
Available on crate feature serde only.
impl Serialize for BlockHeightInterval
serde only.Source§fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
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§fn sub(
self,
rhs: &BlockHeightInterval,
) -> <&BlockHeight as Sub<&'a BlockHeightInterval>>::Output
fn sub( self, rhs: &BlockHeightInterval, ) -> <&BlockHeight as Sub<&'a BlockHeightInterval>>::Output
- operation. Read moreSource§impl<'a> Sub<&'a BlockHeightInterval> for &BlockHeightInterval
impl<'a> Sub<&'a BlockHeightInterval> for &BlockHeightInterval
Source§type Output = <BlockHeightInterval as Sub>::Output
type Output = <BlockHeightInterval as Sub>::Output
- operator.Source§fn sub(
self,
rhs: &BlockHeightInterval,
) -> <&BlockHeightInterval as Sub<&'a BlockHeightInterval>>::Output
fn sub( self, rhs: &BlockHeightInterval, ) -> <&BlockHeightInterval as Sub<&'a BlockHeightInterval>>::Output
- operation. Read moreSource§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§fn sub(
self,
rhs: &BlockHeightInterval,
) -> <BlockHeight as Sub<&BlockHeightInterval>>::Output
fn sub( self, rhs: &BlockHeightInterval, ) -> <BlockHeight as Sub<&BlockHeightInterval>>::Output
- operation. Read moreSource§impl Sub<&BlockHeightInterval> for BlockHeightInterval
impl Sub<&BlockHeightInterval> for BlockHeightInterval
Source§type Output = <BlockHeightInterval as Sub>::Output
type Output = <BlockHeightInterval as Sub>::Output
- operator.Source§fn sub(
self,
rhs: &BlockHeightInterval,
) -> <BlockHeightInterval as Sub<&BlockHeightInterval>>::Output
fn sub( self, rhs: &BlockHeightInterval, ) -> <BlockHeightInterval as Sub<&BlockHeightInterval>>::Output
- operation. Read moreSource§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§fn sub(
self,
rhs: BlockHeightInterval,
) -> <&BlockHeight as Sub<BlockHeightInterval>>::Output
fn sub( self, rhs: BlockHeightInterval, ) -> <&BlockHeight as Sub<BlockHeightInterval>>::Output
- operation. Read moreSource§impl Sub<BlockHeightInterval> for &BlockHeightInterval
impl Sub<BlockHeightInterval> for &BlockHeightInterval
Source§type Output = <BlockHeightInterval as Sub>::Output
type Output = <BlockHeightInterval as Sub>::Output
- operator.Source§fn sub(
self,
rhs: BlockHeightInterval,
) -> <&BlockHeightInterval as Sub<BlockHeightInterval>>::Output
fn sub( self, rhs: BlockHeightInterval, ) -> <&BlockHeightInterval as Sub<BlockHeightInterval>>::Output
- operation. Read moreSource§impl Sub<BlockHeightInterval> for BlockHeight
impl Sub<BlockHeightInterval> for BlockHeight
Source§type Output = BlockHeight
type Output = BlockHeight
- operator.Source§fn sub(
self,
rhs: BlockHeightInterval,
) -> <BlockHeight as Sub<BlockHeightInterval>>::Output
fn sub( self, rhs: BlockHeightInterval, ) -> <BlockHeight as Sub<BlockHeightInterval>>::Output
- operation. Read moreSource§impl Sub for BlockHeightInterval
impl Sub for BlockHeightInterval
Source§type Output = BlockHeightInterval
type Output = BlockHeightInterval
- operator.Source§fn sub(self, rhs: BlockHeightInterval) -> <BlockHeightInterval as Sub>::Output
fn sub(self, rhs: BlockHeightInterval) -> <BlockHeightInterval as Sub>::Output
- operation. Read moreSource§impl SubAssign<&BlockHeightInterval> for BlockHeightInterval
impl SubAssign<&BlockHeightInterval> for BlockHeightInterval
Source§fn sub_assign(&mut self, rhs: &BlockHeightInterval)
fn sub_assign(&mut self, rhs: &BlockHeightInterval)
-= operation. Read moreSource§impl SubAssign for BlockHeightInterval
impl SubAssign for BlockHeightInterval
Source§fn sub_assign(&mut self, rhs: BlockHeightInterval)
fn sub_assign(&mut self, rhs: BlockHeightInterval)
-= operation. Read moreSource§impl<'a> Sum<&'a BlockHeightInterval> for BlockHeightInterval
impl<'a> Sum<&'a BlockHeightInterval> for BlockHeightInterval
Source§fn sum<I>(iter: I) -> BlockHeightIntervalwhere
I: Iterator<Item = &'a BlockHeightInterval>,
fn sum<I>(iter: I) -> BlockHeightIntervalwhere
I: Iterator<Item = &'a BlockHeightInterval>,
Self from the elements by “summing up”
the items.Source§impl Sum for BlockHeightInterval
impl Sum for BlockHeightInterval
Source§fn sum<I>(iter: I) -> BlockHeightIntervalwhere
I: Iterator<Item = BlockHeightInterval>,
fn sum<I>(iter: I) -> BlockHeightIntervalwhere
I: Iterator<Item = BlockHeightInterval>,
Self from the elements by “summing up”
the items.Source§impl TryFrom<&str> for BlockHeightInterval
impl TryFrom<&str> for BlockHeightInterval
Source§type Error = ParseIntError
type Error = ParseIntError
Source§fn try_from(
s: &str,
) -> Result<BlockHeightInterval, <BlockHeightInterval as TryFrom<&str>>::Error>
fn try_from( s: &str, ) -> Result<BlockHeightInterval, <BlockHeightInterval as TryFrom<&str>>::Error>
Source§impl TryFrom<BlockHeightInterval> for NumberOfBlocks
impl TryFrom<BlockHeightInterval> for NumberOfBlocks
Source§fn try_from(
h: BlockHeightInterval,
) -> Result<NumberOfBlocks, <NumberOfBlocks as TryFrom<BlockHeightInterval>>::Error>
fn try_from( h: BlockHeightInterval, ) -> Result<NumberOfBlocks, <NumberOfBlocks as TryFrom<BlockHeightInterval>>::Error>
Converts a BlockHeightInterval to a [locktime::relative::NumberOfBlocks].
A relative locktime block height has a maximum value of u16::MAX where as a
BlockHeightInterval is a thin wrapper around a u32, the two types are not interchangeable.
Source§type Error = TooBigForRelativeHeightError
type Error = TooBigForRelativeHeightError
Source§impl TryFrom<String> for BlockHeightInterval
Available on crate feature alloc only.
impl TryFrom<String> for BlockHeightInterval
alloc only.