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 · sourceconst fn max(self, other: Self) -> Selfwhere
Self: Sized,
const fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourceconst fn min(self, other: Self) -> Selfwhere
Self: Sized,
const fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourceconst fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
const fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + 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>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const 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 moreimpl 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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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