pub struct BlockMtpInterval(/* private fields */);Expand description
An unsigned difference between two BlockMtps.
This type is not meant for constructing time-based timelocks. It is a general purpose
MTP abstraction. For locktimes please see locktime::relative::NumberOf512Seconds.
This is a thin wrapper around a u32 that may take on all values of a u32.
Implementations§
Source§impl BlockMtpInterval
impl BlockMtpInterval
Sourcepub const fn to_relative_mtp_interval_floor(
self,
) -> Result<NumberOf512Seconds, TimeOverflowError>
pub const fn to_relative_mtp_interval_floor( self, ) -> Result<NumberOf512Seconds, TimeOverflowError>
Converts a BlockMtpInterval to a locktime::relative::NumberOf512Seconds, rounding down.
Relative timelock MTP intervals have a resolution of 512 seconds, while
BlockMtpInterval, like all block timestamp types, has a one-second resolution.
§Errors
Errors if the MTP is out-of-range (in excess of 512 times u16::MAX seconds, or about
388 days) for a time-based relative locktime.
Sourcepub const fn to_relative_mtp_interval_ceil(
self,
) -> Result<NumberOf512Seconds, TimeOverflowError>
pub const fn to_relative_mtp_interval_ceil( self, ) -> Result<NumberOf512Seconds, TimeOverflowError>
Converts a BlockMtpInterval to a locktime::relative::NumberOf512Seconds, rounding up.
Relative timelock MTP intervals have a resolution of 512 seconds, while
BlockMtpInterval, like all block timestamp types, has a one-second resolution.
§Errors
Errors if the MTP is out-of-range (in excess of 512 times u16::MAX seconds, or about
388 days) for a time-based relative locktime.
Sourcepub fn checked_sub(self, other: Self) -> Option<Self>
pub fn checked_sub(self, other: Self) -> Option<Self>
Attempt to subtract two BlockMtpIntervals, returning None if overflow occurred.
Sourcepub fn checked_add(self, other: Self) -> Option<Self>
pub fn checked_add(self, other: Self) -> Option<Self>
Attempt to add two BlockMtpIntervals, returning None if overflow occurred.
Trait Implementations§
Source§impl<'a> Add<&'a BlockMtpInterval> for &BlockMtp
impl<'a> Add<&'a BlockMtpInterval> for &BlockMtp
Source§impl<'a> Add<&'a BlockMtpInterval> for &BlockMtpInterval
impl<'a> Add<&'a BlockMtpInterval> for &BlockMtpInterval
Source§impl Add<&BlockMtpInterval> for BlockMtp
impl Add<&BlockMtpInterval> for BlockMtp
Source§impl Add<&BlockMtpInterval> for BlockMtpInterval
impl Add<&BlockMtpInterval> for BlockMtpInterval
Source§impl Add<BlockMtpInterval> for &BlockMtp
impl Add<BlockMtpInterval> for &BlockMtp
Source§impl Add<BlockMtpInterval> for &BlockMtpInterval
impl Add<BlockMtpInterval> for &BlockMtpInterval
Source§impl Add<BlockMtpInterval> for BlockMtp
impl Add<BlockMtpInterval> for BlockMtp
Source§impl Add for BlockMtpInterval
impl Add for BlockMtpInterval
Source§type Output = BlockMtpInterval
type Output = BlockMtpInterval
+ operator.Source§impl AddAssign<&BlockMtpInterval> for BlockMtpInterval
impl AddAssign<&BlockMtpInterval> for BlockMtpInterval
Source§fn add_assign(&mut self, rhs: &BlockMtpInterval)
fn add_assign(&mut self, rhs: &BlockMtpInterval)
+= operation. Read moreSource§impl AddAssign for BlockMtpInterval
impl AddAssign for BlockMtpInterval
Source§fn add_assign(&mut self, rhs: BlockMtpInterval)
fn add_assign(&mut self, rhs: BlockMtpInterval)
+= operation. Read moreSource§impl<'a> Arbitrary<'a> for BlockMtpInterval
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for BlockMtpInterval
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 BlockMtpInterval
impl Binary for BlockMtpInterval
Source§impl Clone for BlockMtpInterval
impl Clone for BlockMtpInterval
Source§fn clone(&self) -> BlockMtpInterval
fn clone(&self) -> BlockMtpInterval
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BlockMtpInterval
impl Debug for BlockMtpInterval
Source§impl Default for BlockMtpInterval
impl Default for BlockMtpInterval
Source§fn default() -> BlockMtpInterval
fn default() -> BlockMtpInterval
Source§impl<'de> Deserialize<'de> for BlockMtpInterval
Available on crate feature serde only.
impl<'de> Deserialize<'de> for BlockMtpInterval
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 BlockMtpInterval
impl Display for BlockMtpInterval
Source§impl From<BlockMtpInterval> for u32
impl From<BlockMtpInterval> for u32
Source§fn from(height: BlockMtpInterval) -> Self
fn from(height: BlockMtpInterval) -> Self
Source§impl From<NumberOf512Seconds> for BlockMtpInterval
impl From<NumberOf512Seconds> for BlockMtpInterval
Source§fn from(h: NumberOf512Seconds) -> Self
fn from(h: NumberOf512Seconds) -> Self
Converts a locktime::relative::NumberOf512Seconds to a BlockMtpInterval.
A relative locktime MTP interval has a resolution of 512 seconds, and a maximum value
of u16::MAX 512-second intervals. BlockMtpInterval may take the full range of
u32.
Source§impl From<u32> for BlockMtpInterval
impl From<u32> for BlockMtpInterval
Source§impl FromStr for BlockMtpInterval
impl FromStr for BlockMtpInterval
Source§impl Hash for BlockMtpInterval
impl Hash for BlockMtpInterval
Source§impl LowerHex for BlockMtpInterval
impl LowerHex for BlockMtpInterval
Source§impl Octal for BlockMtpInterval
impl Octal for BlockMtpInterval
Source§impl Ord for BlockMtpInterval
impl Ord for BlockMtpInterval
Source§fn cmp(&self, other: &BlockMtpInterval) -> Ordering
fn cmp(&self, other: &BlockMtpInterval) -> 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 BlockMtpInterval
impl PartialEq for BlockMtpInterval
Source§impl PartialOrd for BlockMtpInterval
impl PartialOrd for BlockMtpInterval
Source§impl Serialize for BlockMtpInterval
Available on crate feature serde only.
impl Serialize for BlockMtpInterval
serde only.Source§impl<'a> Sub<&'a BlockMtpInterval> for &BlockMtp
impl<'a> Sub<&'a BlockMtpInterval> for &BlockMtp
Source§impl<'a> Sub<&'a BlockMtpInterval> for &BlockMtpInterval
impl<'a> Sub<&'a BlockMtpInterval> for &BlockMtpInterval
Source§impl Sub<&BlockMtpInterval> for BlockMtp
impl Sub<&BlockMtpInterval> for BlockMtp
Source§impl Sub<&BlockMtpInterval> for BlockMtpInterval
impl Sub<&BlockMtpInterval> for BlockMtpInterval
Source§impl Sub<BlockMtpInterval> for &BlockMtp
impl Sub<BlockMtpInterval> for &BlockMtp
Source§impl Sub<BlockMtpInterval> for &BlockMtpInterval
impl Sub<BlockMtpInterval> for &BlockMtpInterval
Source§impl Sub<BlockMtpInterval> for BlockMtp
impl Sub<BlockMtpInterval> for BlockMtp
Source§impl Sub for BlockMtpInterval
impl Sub for BlockMtpInterval
Source§type Output = BlockMtpInterval
type Output = BlockMtpInterval
- operator.Source§impl SubAssign<&BlockMtpInterval> for BlockMtpInterval
impl SubAssign<&BlockMtpInterval> for BlockMtpInterval
Source§fn sub_assign(&mut self, rhs: &BlockMtpInterval)
fn sub_assign(&mut self, rhs: &BlockMtpInterval)
-= operation. Read moreSource§impl SubAssign for BlockMtpInterval
impl SubAssign for BlockMtpInterval
Source§fn sub_assign(&mut self, rhs: BlockMtpInterval)
fn sub_assign(&mut self, rhs: BlockMtpInterval)
-= operation. Read moreSource§impl<'a> Sum<&'a BlockMtpInterval> for BlockMtpInterval
impl<'a> Sum<&'a BlockMtpInterval> for BlockMtpInterval
Source§impl Sum for BlockMtpInterval
impl Sum for BlockMtpInterval
Source§impl TryFrom<&str> for BlockMtpInterval
impl TryFrom<&str> for BlockMtpInterval
Source§impl TryFrom<String> for BlockMtpInterval
Available on crate feature alloc only.
impl TryFrom<String> for BlockMtpInterval
alloc only.