Struct bitcoin_units::FeeRate
source · pub struct FeeRate(/* private fields */);
alloc
only.Expand description
Represents fee rate.
This is an integer newtype representing fee rate in sat/kwu
. It provides protection against mixing
up the types as well as basic formatting features.
Implementations§
source§impl FeeRate
impl FeeRate
sourcepub const ZERO: FeeRate = _
pub const ZERO: FeeRate = _
0 sat/kwu.
Equivalent to MIN
, may better express intent in some contexts.
sourcepub const MIN: FeeRate = FeeRate::ZERO
pub const MIN: FeeRate = FeeRate::ZERO
Minimum possible value (0 sat/kwu).
Equivalent to ZERO
, may better express intent in some contexts.
sourcepub const BROADCAST_MIN: FeeRate = _
pub const BROADCAST_MIN: FeeRate = _
Minimum fee rate required to broadcast a transaction.
The value matches the default Bitcoin Core policy at the time of library release.
sourcepub const fn from_sat_per_kwu(sat_kwu: u64) -> Self
pub const fn from_sat_per_kwu(sat_kwu: u64) -> Self
Constructs FeeRate
from satoshis per 1000 weight units.
sourcepub fn from_sat_per_vb(sat_vb: u64) -> Option<Self>
pub fn from_sat_per_vb(sat_vb: u64) -> Option<Self>
sourcepub const fn from_sat_per_vb_unchecked(sat_vb: u64) -> Self
pub const fn from_sat_per_vb_unchecked(sat_vb: u64) -> Self
Constructs FeeRate
from satoshis per virtual bytes without overflow check.
sourcepub const fn to_sat_per_kwu(self) -> u64
pub const fn to_sat_per_kwu(self) -> u64
Returns raw fee rate.
Can be used instead of into()
to avoid inference issues.
sourcepub const fn to_sat_per_vb_floor(self) -> u64
pub const fn to_sat_per_vb_floor(self) -> u64
Converts to sat/vB rounding down.
sourcepub const fn to_sat_per_vb_ceil(self) -> u64
pub const fn to_sat_per_vb_ceil(self) -> u64
Converts to sat/vB rounding up.
sourcepub fn checked_mul(self, rhs: u64) -> Option<Self>
pub fn checked_mul(self, rhs: u64) -> Option<Self>
Checked multiplication.
Computes self * rhs
returning None
if overflow occurred.
sourcepub fn checked_div(self, rhs: u64) -> Option<Self>
pub fn checked_div(self, rhs: u64) -> Option<Self>
Checked division.
Computes self / rhs
returning None
if rhs == 0
.
sourcepub fn checked_mul_by_weight(self, rhs: Weight) -> Option<Amount>
pub fn checked_mul_by_weight(self, rhs: Weight) -> Option<Amount>
Checked weight multiplication.
Computes the absolute fee amount for a given Weight
at this fee rate.
None
is returned if an overflow occurred.
Trait Implementations§
source§impl<'de> Deserialize<'de> for FeeRate
impl<'de> Deserialize<'de> for FeeRate
source§fn 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>,
source§impl Ord for FeeRate
impl Ord for FeeRate
source§impl PartialEq for FeeRate
impl PartialEq for FeeRate
source§impl PartialOrd for FeeRate
impl PartialOrd for FeeRate
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Copy for FeeRate
impl Eq for FeeRate
impl StructuralPartialEq for FeeRate
Auto Trait Implementations§
impl Freeze for FeeRate
impl RefUnwindSafe for FeeRate
impl Send for FeeRate
impl Sync for FeeRate
impl Unpin for FeeRate
impl UnwindSafe for FeeRate
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)