Add missing links
The use of links in the rustdocs was inconsistent. Links have been added when missing. [`locktime::absolute::Height`] and [`locktime::relative::Height`] did not work and `(crate::locktime)` was appended to fix it.
This commit is contained in:
parent
47e367f011
commit
6dd5af9678
|
@ -122,10 +122,10 @@ impl FromStr for Denomination {
|
|||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// - If the denomination begins with a capital `M` a `PossiblyConfusingDenominationError` is
|
||||
/// - If the denomination begins with a capital `M` a [`PossiblyConfusingDenominationError`] is
|
||||
/// returned.
|
||||
///
|
||||
/// - If an unknown denomination is used, an `UnknownDenominationError` is returned.
|
||||
/// - If an unknown denomination is used, an [`UnknownDenominationError`] is returned.
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
use self::ParseDenominationError::*;
|
||||
|
||||
|
@ -525,7 +525,7 @@ fn is_too_precise(s: &str, precision: usize) -> Option<usize> {
|
|||
const INPUT_STRING_LEN_LIMIT: usize = 50;
|
||||
|
||||
/// Parses a decimal string in the given denomination into a satoshi value and a
|
||||
/// `bool` indicator for a negative amount.
|
||||
/// [`bool`] indicator for a negative amount.
|
||||
fn parse_signed_to_satoshi(
|
||||
mut s: &str,
|
||||
denom: Denomination,
|
||||
|
@ -1017,7 +1017,7 @@ impl Amount {
|
|||
self.display_in(denom).show_denomination().to_string()
|
||||
}
|
||||
|
||||
// Some arithmetic that doesn't fit in `core::ops` traits.
|
||||
// Some arithmetic that doesn't fit in [`core::ops`] traits.
|
||||
|
||||
/// Checked addition.
|
||||
///
|
||||
|
@ -1173,13 +1173,13 @@ impl core::iter::Sum for Amount {
|
|||
|
||||
/// A helper/builder that displays amount with specified settings.
|
||||
///
|
||||
/// This provides richer interface than `fmt::Formatter`:
|
||||
/// This provides richer interface than [`fmt::Formatter`]:
|
||||
///
|
||||
/// * Ability to select denomination
|
||||
/// * Show or hide denomination
|
||||
/// * Dynamically-selected denomination - show in sats if less than 1 BTC.
|
||||
///
|
||||
/// However this can still be combined with `fmt::Formatter` options to precisely control zeros,
|
||||
/// However this can still be combined with [`fmt::Formatter`] options to precisely control zeros,
|
||||
/// padding, alignment... The formatting works like floats from `core` but note that precision will
|
||||
/// **never** be lossy - that means no rounding.
|
||||
///
|
||||
|
@ -1376,12 +1376,12 @@ impl SignedAmount {
|
|||
self.display_in(denom).show_denomination().to_string()
|
||||
}
|
||||
|
||||
// Some arithmetic that doesn't fit in `core::ops` traits.
|
||||
// Some arithmetic that doesn't fit in [`core::ops`] traits.
|
||||
|
||||
/// Get the absolute value of this [`SignedAmount`].
|
||||
pub fn abs(self) -> SignedAmount { SignedAmount(self.0.abs()) }
|
||||
|
||||
/// Get the absolute value of this [`SignedAmount`] returning `Amount`.
|
||||
/// Get the absolute value of this [`SignedAmount`] returning [`Amount`].
|
||||
pub fn unsigned_abs(self) -> Amount { Amount(self.0.unsigned_abs()) }
|
||||
|
||||
/// Returns a number representing sign of this [`SignedAmount`].
|
||||
|
@ -1593,7 +1593,7 @@ impl core::iter::Sum for SignedAmount {
|
|||
/// Calculates the sum over the iterator using checked arithmetic.
|
||||
pub trait CheckedSum<R>: private::SumSeal<R> {
|
||||
/// Calculates the sum over the iterator using checked arithmetic. If an over or underflow would
|
||||
/// happen it returns `None`.
|
||||
/// happen it returns [`None`].
|
||||
fn checked_sum(self) -> Option<R>;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,10 +65,10 @@ impl From<BlockHeight> for u32 {
|
|||
}
|
||||
|
||||
impl From<absolute::Height> for BlockHeight {
|
||||
/// Converts [`locktime::absolute::Height`] to a [`BlockHeight`].
|
||||
/// Converts a [`locktime::absolute::Height`] to a [`BlockHeight`].
|
||||
///
|
||||
/// An absolute locktime block height has a maximum value of `absolute::LOCK_TIME_THRESHOLD`
|
||||
/// (500,000,000) where as a `BlockHeight` is a thin wrapper around a `u32`, the two types are
|
||||
/// An absolute locktime block height has a maximum value of [`absolute::LOCK_TIME_THRESHOLD`]
|
||||
/// (500,000,000) where as a [`BlockHeight`] is a thin wrapper around a `u32`, the two types are
|
||||
/// not interchangeable.
|
||||
fn from(h: absolute::Height) -> Self { Self::from_u32(h.to_consensus_u32()) }
|
||||
}
|
||||
|
@ -76,10 +76,10 @@ impl From<absolute::Height> for BlockHeight {
|
|||
impl TryFrom<BlockHeight> for absolute::Height {
|
||||
type Error = absolute::ConversionError;
|
||||
|
||||
/// Converts [`BlockHeight`] to a [`locktime::absolute::Height`].
|
||||
/// Converts a [`BlockHeight`] to a [`locktime::absolute::Height`].
|
||||
///
|
||||
/// An absolute locktime block height has a maximum value of `absolute::LOCK_TIME_THRESHOLD`
|
||||
/// (500,000,000) where as a `BlockHeight` is a thin wrapper around a `u32`, the two types are
|
||||
/// An absolute locktime block height has a maximum value of [`absolute::LOCK_TIME_THRESHOLD`]
|
||||
/// (500,000,000) where as a [`BlockHeight`] is a thin wrapper around a `u32`, the two types are
|
||||
/// not interchangeable.
|
||||
fn try_from(h: BlockHeight) -> Result<Self, Self::Error> {
|
||||
absolute::Height::from_consensus(h.to_u32())
|
||||
|
@ -132,20 +132,20 @@ impl From<BlockInterval> for u32 {
|
|||
}
|
||||
|
||||
impl From<relative::Height> for BlockInterval {
|
||||
/// Converts [`locktime::relative::Height`] to a [`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.
|
||||
/// [`BlockInterval`] is a thin wrapper around a `u32`, the two types are not interchangeable.
|
||||
fn from(h: relative::Height) -> Self { Self::from_u32(h.value().into()) }
|
||||
}
|
||||
|
||||
impl TryFrom<BlockInterval> for relative::Height {
|
||||
type Error = TooBigForRelativeBlockHeightError;
|
||||
|
||||
/// Converts [`BlockInterval`] to a [`locktime::relative::Height`].
|
||||
/// 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.
|
||||
/// [`BlockInterval`] is a thin wrapper around a `u32`, the two types are not interchangeable.
|
||||
fn try_from(h: BlockInterval) -> Result<Self, Self::Error> {
|
||||
let h = h.to_u32();
|
||||
if h > u16::MAX as u32 {
|
||||
|
|
|
@ -42,14 +42,14 @@ impl FeeRate {
|
|||
/// Fee rate used to compute dust amount.
|
||||
pub const DUST: FeeRate = FeeRate::from_sat_per_vb_unchecked(3);
|
||||
|
||||
/// Constructs `FeeRate` from satoshis per 1000 weight units.
|
||||
/// Constructs [`FeeRate`] from satoshis per 1000 weight units.
|
||||
pub const fn from_sat_per_kwu(sat_kwu: u64) -> Self { FeeRate(sat_kwu) }
|
||||
|
||||
/// Constructs `FeeRate` from satoshis per virtual bytes.
|
||||
/// Constructs [`FeeRate`] from satoshis per virtual bytes.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns `None` on arithmetic overflow.
|
||||
/// Returns [`None`] on arithmetic overflow.
|
||||
pub fn from_sat_per_vb(sat_vb: u64) -> Option<Self> {
|
||||
// 1 vb == 4 wu
|
||||
// 1 sat/vb == 1/4 sat/wu
|
||||
|
@ -57,7 +57,7 @@ impl FeeRate {
|
|||
Some(FeeRate(sat_vb.checked_mul(1000 / 4)?))
|
||||
}
|
||||
|
||||
/// Constructs `FeeRate` from satoshis per virtual bytes without overflow check.
|
||||
/// Constructs [`FeeRate`] from satoshis per virtual bytes without overflow check.
|
||||
pub const fn from_sat_per_vb_unchecked(sat_vb: u64) -> Self { FeeRate(sat_vb * (1000 / 4)) }
|
||||
|
||||
/// Returns raw fee rate.
|
||||
|
@ -73,34 +73,34 @@ impl FeeRate {
|
|||
|
||||
/// Checked multiplication.
|
||||
///
|
||||
/// Computes `self * rhs` returning `None` if overflow occurred.
|
||||
/// Computes `self * rhs` returning [`None`] if overflow occurred.
|
||||
pub fn checked_mul(self, rhs: u64) -> Option<Self> { self.0.checked_mul(rhs).map(Self) }
|
||||
|
||||
/// Checked division.
|
||||
///
|
||||
/// Computes `self / rhs` returning `None` if `rhs == 0`.
|
||||
/// Computes `self / rhs` returning [`None`] if `rhs == 0`.
|
||||
pub fn checked_div(self, rhs: u64) -> Option<Self> { self.0.checked_div(rhs).map(Self) }
|
||||
|
||||
/// Checked weight multiplication.
|
||||
///
|
||||
/// Computes the absolute fee amount for a given [`Weight`] at this fee rate.
|
||||
///
|
||||
/// `None` is returned if an overflow occurred.
|
||||
/// [`None`] is returned if an overflow occurred.
|
||||
pub fn checked_mul_by_weight(self, rhs: Weight) -> Option<Amount> {
|
||||
let sats = self.0.checked_mul(rhs.to_wu())?.checked_add(999)? / 1000;
|
||||
Some(Amount::from_sat(sats))
|
||||
}
|
||||
|
||||
/// Calculates the fee by multiplying this fee rate by weight, in weight units, returning `None`
|
||||
/// Calculates the fee by multiplying this fee rate by weight, in weight units, returning [`None`]
|
||||
/// if an overflow occurred.
|
||||
///
|
||||
/// This is equivalent to `Self::checked_mul_by_weight()`.
|
||||
pub fn fee_wu(self, weight: Weight) -> Option<Amount> { self.checked_mul_by_weight(weight) }
|
||||
|
||||
/// Calculates the fee by multiplying this fee rate by weight, in virtual bytes, returning `None`
|
||||
/// Calculates the fee by multiplying this fee rate by weight, in virtual bytes, returning [`None`]
|
||||
/// if an overflow occurred.
|
||||
///
|
||||
/// This is equivalent to converting `vb` to `weight` using `Weight::from_vb` and then calling
|
||||
/// This is equivalent to converting `vb` to [`Weight`] using [`Weight::from_vb`] and then calling
|
||||
/// `Self::fee_wu(weight)`.
|
||||
pub fn fee_vb(self, vb: u64) -> Option<Amount> {
|
||||
Weight::from_vb(vb).and_then(|w| self.fee_wu(w))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
//! Provides `Height` and `Time` types used by the `rust-bitcoin` `absolute::LockTime` type.
|
||||
//! Provides [`Height`] and [`Time`] types used by the `rust-bitcoin` `absolute::LockTime` type.
|
||||
|
||||
use core::fmt;
|
||||
|
||||
|
@ -39,7 +39,7 @@ impl Height {
|
|||
/// The maximum absolute block height.
|
||||
pub const MAX: Self = Height(LOCK_TIME_THRESHOLD - 1);
|
||||
|
||||
/// Creates a `Height` from a hex string.
|
||||
/// Creates a [`Height`] from a hex string.
|
||||
///
|
||||
/// The input string may or may not contain a typical hex prefix e.g., `0x`.
|
||||
pub fn from_hex(s: &str) -> Result<Self, ParseHeightError> {
|
||||
|
@ -70,7 +70,7 @@ impl Height {
|
|||
}
|
||||
}
|
||||
|
||||
/// Converts this `Height` to its inner `u32` value.
|
||||
/// Converts this [`Height`] to its inner `u32` value.
|
||||
#[inline]
|
||||
pub fn to_consensus_u32(self) -> u32 { self.0 }
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ impl Time {
|
|||
/// The maximum absolute block time (Sun Feb 07 2106 06:28:15 GMT+0000).
|
||||
pub const MAX: Self = Time(u32::MAX);
|
||||
|
||||
/// Creates a `Time` from a hex string.
|
||||
/// Creates a [`Time`] from a hex string.
|
||||
///
|
||||
/// The input string may or may not contain a typical hex prefix e.g., `0x`.
|
||||
pub fn from_hex(s: &str) -> Result<Self, ParseTimeError> { parse_hex(s, Self::from_consensus) }
|
||||
|
@ -166,7 +166,7 @@ impl Time {
|
|||
}
|
||||
}
|
||||
|
||||
/// Converts this `Time` to its inner `u32` value.
|
||||
/// Converts this [`Time`] to its inner `u32` value.
|
||||
#[inline]
|
||||
pub fn to_consensus_u32(self) -> u32 { self.0 }
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
//! Provides `Height` and `Time` types used by the `rust-bitcoin` `relative::LockTime` type.
|
||||
//! Provides [`Height`] and [`Time`] types used by the `rust-bitcoin` `relative::LockTime` type.
|
||||
|
||||
use core::fmt;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ pub const WITNESS_SCALE_FACTOR: usize = 4;
|
|||
|
||||
/// Represents block weight - the weight of a transaction or block.
|
||||
///
|
||||
/// This is an integer newtype representing weigth in `wu`. It provides protection against mixing
|
||||
/// This is an integer newtype representing [`Weight`] in `wu`. It provides protection against mixing
|
||||
/// up the types as well as basic formatting features.
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
@ -43,21 +43,21 @@ impl Weight {
|
|||
/// The minimum transaction weight for a valid serialized transaction.
|
||||
pub const MIN_TRANSACTION: Weight = Weight(Self::WITNESS_SCALE_FACTOR * 60);
|
||||
|
||||
/// Directly constructs `Weight` from weight units.
|
||||
/// Directly constructs [`Weight`] from weight units.
|
||||
pub const fn from_wu(wu: u64) -> Self { Weight(wu) }
|
||||
|
||||
/// Directly constructs `Weight` from usize weight units.
|
||||
/// Directly constructs [`Weight`] from usize weight units.
|
||||
pub const fn from_wu_usize(wu: usize) -> Self { Weight(wu as u64) }
|
||||
|
||||
/// Constructs `Weight` from kilo weight units returning `None` if an overflow occurred.
|
||||
/// Constructs [`Weight`] from kilo weight units returning [`None`] if an overflow occurred.
|
||||
pub fn from_kwu(wu: u64) -> Option<Self> { wu.checked_mul(1000).map(Weight) }
|
||||
|
||||
/// Constructs `Weight` from virtual bytes, returning `None` if an overflow occurred.
|
||||
/// Constructs [`Weight`] from virtual bytes, returning [`None`] if an overflow occurred.
|
||||
pub fn from_vb(vb: u64) -> Option<Self> {
|
||||
vb.checked_mul(Self::WITNESS_SCALE_FACTOR).map(Weight::from_wu)
|
||||
}
|
||||
|
||||
/// Constructs `Weight` from virtual bytes panicking if an overflow occurred.
|
||||
/// Constructs [`Weight`] from virtual bytes panicking if an overflow occurred.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
|
@ -76,13 +76,13 @@ impl Weight {
|
|||
}
|
||||
}
|
||||
|
||||
/// Constructs `Weight` from virtual bytes without an overflow check.
|
||||
/// Constructs [`Weight`] from virtual bytes without an overflow check.
|
||||
pub const fn from_vb_unchecked(vb: u64) -> Self { Weight::from_wu(vb * 4) }
|
||||
|
||||
/// Constructs `Weight` from witness size.
|
||||
/// Constructs [`Weight`] from witness size.
|
||||
pub const fn from_witness_data_size(witness_size: u64) -> Self { Weight(witness_size) }
|
||||
|
||||
/// Constructs `Weight` from non-witness size.
|
||||
/// Constructs [`Weight`] from non-witness size.
|
||||
pub const fn from_non_witness_data_size(non_witness_size: u64) -> Self {
|
||||
Weight(non_witness_size * Self::WITNESS_SCALE_FACTOR)
|
||||
}
|
||||
|
@ -105,22 +105,22 @@ impl Weight {
|
|||
|
||||
/// Checked addition.
|
||||
///
|
||||
/// Computes `self + rhs` returning `None` if an overflow occurred.
|
||||
/// Computes `self + rhs` returning [`None`] if an overflow occurred.
|
||||
pub fn checked_add(self, rhs: Self) -> Option<Self> { self.0.checked_add(rhs.0).map(Self) }
|
||||
|
||||
/// Checked subtraction.
|
||||
///
|
||||
/// Computes `self - rhs` returning `None` if an overflow occurred.
|
||||
/// Computes `self - rhs` returning [`None`] if an overflow occurred.
|
||||
pub fn checked_sub(self, rhs: Self) -> Option<Self> { self.0.checked_sub(rhs.0).map(Self) }
|
||||
|
||||
/// Checked multiplication.
|
||||
///
|
||||
/// Computes `self * rhs` returning `None` if an overflow occurred.
|
||||
/// Computes `self * rhs` returning [`None`] if an overflow occurred.
|
||||
pub fn checked_mul(self, rhs: u64) -> Option<Self> { self.0.checked_mul(rhs).map(Self) }
|
||||
|
||||
/// Checked division.
|
||||
///
|
||||
/// Computes `self / rhs` returning `None` if `rhs == 0`.
|
||||
/// Computes `self / rhs` returning [`None`] if `rhs == 0`.
|
||||
pub fn checked_div(self, rhs: u64) -> Option<Self> { self.0.checked_div(rhs).map(Self) }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue