pub struct Height(_);
Expand description
An absolute block height, guaranteed to always contain a valid height value.
Implementations
sourceimpl Height
impl Height
sourcepub fn from_consensus(n: u32) -> Result<Height, Error>
pub fn from_consensus(n: u32) -> Result<Height, Error>
Constructs a new block height.
Errors
If n
does not represent a block height value (see documentation on LockTime
).
Examples
use bitcoin::blockdata::locktime::Height;
let h: u32 = 741521;
let height = Height::from_consensus(h).expect("invalid height value");
assert_eq!(height.to_consensus_u32(), h);
sourcepub fn to_consensus_u32(self) -> u32
pub fn to_consensus_u32(self) -> u32
Converts this Height
to its inner u32
value.
Examples
use bitcoin::LockTime;
let n_lock_time: u32 = 741521;
let lock_time = LockTime::from_consensus(n_lock_time);
assert!(lock_time.is_block_height());
assert_eq!(lock_time.to_consensus_u32(), n_lock_time);
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Height
impl<'de> Deserialize<'de> for Height
sourcefn 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
sourceimpl Ord for Height
impl Ord for Height
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Height> for Height
impl PartialOrd<Height> for Height
sourcefn partial_cmp(&self, other: &Height) -> Option<Ordering>
fn partial_cmp(&self, other: &Height) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for Height
impl Eq for Height
impl StructuralEq for Height
impl StructuralPartialEq for Height
Auto Trait Implementations
impl RefUnwindSafe for Height
impl Send for Height
impl Sync for Height
impl Unpin for Height
impl UnwindSafe for Height
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more