pub struct BlockInterval(pub u32);
alloc
only.Expand description
The block interval.
Block interval is an integer type denoting the number of blocks that has passed since some point i.e., this type is meant for usage as a relative block measure.
This type is not meant for constructing relative height based timelocks, this is a general
purpose block interval abstraction. For locktimes please see [locktime::relative::Height
].
Tuple Fields§
§0: u32
Implementations§
Source§impl BlockInterval
impl BlockInterval
Sourcepub const ZERO: BlockInterval
pub const ZERO: BlockInterval
Block interval 0 i.e., the current block.
Sourcepub const MIN: BlockInterval = Self::ZERO
pub const MIN: BlockInterval = Self::ZERO
The minimum block interval (0).
Sourcepub const MAX: BlockInterval
pub const MAX: BlockInterval
The maximum block interval.
Sourcepub const fn from_u32(inner: u32) -> BlockInterval
pub const fn from_u32(inner: u32) -> BlockInterval
Creates a block interval from a u32
.
Trait Implementations§
Source§impl Add<BlockInterval> for BlockHeight
impl Add<BlockInterval> for BlockHeight
Source§type Output = BlockHeight
type Output = BlockHeight
+
operator.Source§fn add(self, rhs: BlockInterval) -> <BlockHeight as Add<BlockInterval>>::Output
fn add(self, rhs: BlockInterval) -> <BlockHeight as Add<BlockInterval>>::Output
+
operation. Read moreSource§impl Add for BlockInterval
impl Add for BlockInterval
Source§type Output = BlockInterval
type Output = BlockInterval
+
operator.Source§fn add(self, rhs: BlockInterval) -> <BlockInterval as Add>::Output
fn add(self, rhs: BlockInterval) -> <BlockInterval as Add>::Output
+
operation. Read moreSource§impl AddAssign for BlockInterval
impl AddAssign for BlockInterval
Source§fn add_assign(&mut self, rhs: BlockInterval)
fn add_assign(&mut self, rhs: BlockInterval)
+=
operation. Read moreSource§impl Clone for BlockInterval
impl Clone for BlockInterval
Source§fn clone(&self) -> BlockInterval
fn clone(&self) -> BlockInterval
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for BlockInterval
impl Debug for BlockInterval
Source§impl<'de> Deserialize<'de> for BlockInterval
impl<'de> Deserialize<'de> for BlockInterval
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<BlockInterval, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<BlockInterval, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for BlockInterval
impl Display for BlockInterval
Source§impl From<Height> for BlockInterval
impl From<Height> for BlockInterval
Source§fn from(h: Height) -> BlockInterval
fn from(h: Height) -> BlockInterval
Converts a [locktime::relative::Height
] to a BlockInterval
.
A relative locktime block height has a maximum value of u16::MAX
where as a
BlockInterval
is a thin wrapper around a u32
, the two types are not interchangeable.
Source§impl From<u32> for BlockInterval
impl From<u32> for BlockInterval
Source§fn from(inner: u32) -> BlockInterval
fn from(inner: u32) -> BlockInterval
Source§impl FromStr for BlockInterval
impl FromStr for BlockInterval
Source§type Err = ParseIntError
type Err = ParseIntError
Source§fn from_str(s: &str) -> Result<BlockInterval, <BlockInterval as FromStr>::Err>
fn from_str(s: &str) -> Result<BlockInterval, <BlockInterval as FromStr>::Err>
s
to return a value of this type. Read moreSource§impl Hash for BlockInterval
impl Hash for BlockInterval
Source§impl Ord for BlockInterval
impl Ord for BlockInterval
Source§fn cmp(&self, other: &BlockInterval) -> Ordering
fn cmp(&self, other: &BlockInterval) -> 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 BlockInterval
impl PartialEq for BlockInterval
Source§impl PartialOrd for BlockInterval
impl PartialOrd for BlockInterval
Source§impl Serialize for BlockInterval
impl Serialize for BlockInterval
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl Sub<BlockInterval> for BlockHeight
impl Sub<BlockInterval> for BlockHeight
Source§type Output = BlockHeight
type Output = BlockHeight
-
operator.Source§fn sub(self, rhs: BlockInterval) -> <BlockHeight as Sub<BlockInterval>>::Output
fn sub(self, rhs: BlockInterval) -> <BlockHeight as Sub<BlockInterval>>::Output
-
operation. Read moreSource§impl Sub for BlockInterval
impl Sub for BlockInterval
Source§type Output = BlockInterval
type Output = BlockInterval
-
operator.Source§fn sub(self, rhs: BlockInterval) -> <BlockInterval as Sub>::Output
fn sub(self, rhs: BlockInterval) -> <BlockInterval as Sub>::Output
-
operation. Read moreSource§impl SubAssign for BlockInterval
impl SubAssign for BlockInterval
Source§fn sub_assign(&mut self, rhs: BlockInterval)
fn sub_assign(&mut self, rhs: BlockInterval)
-=
operation. Read moreSource§impl TryFrom<&str> for BlockInterval
impl TryFrom<&str> for BlockInterval
Source§type Error = ParseIntError
type Error = ParseIntError
Source§fn try_from(
s: &str,
) -> Result<BlockInterval, <BlockInterval as TryFrom<&str>>::Error>
fn try_from( s: &str, ) -> Result<BlockInterval, <BlockInterval as TryFrom<&str>>::Error>
Source§impl TryFrom<BlockInterval> for Height
impl TryFrom<BlockInterval> for Height
Source§fn try_from(
h: BlockInterval,
) -> Result<Height, <Height as TryFrom<BlockInterval>>::Error>
fn try_from( h: BlockInterval, ) -> Result<Height, <Height as TryFrom<BlockInterval>>::Error>
Converts a BlockInterval
to a [locktime::relative::Height
].
A relative locktime block height has a maximum value of u16::MAX
where as a
BlockInterval
is a thin wrapper around a u32
, the two types are not interchangeable.