Skip to content

Commit 5ee9a90

Browse files
committed
f Fix non-std docs for lightning
1 parent 8230f52 commit 5ee9a90

File tree

13 files changed

+51
-46
lines changed

13 files changed

+51
-46
lines changed

lightning/src/events/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -543,12 +543,13 @@ pub enum PaymentFailureReason {
543543
///
544544
/// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment
545545
UserAbandoned,
546-
/// We exhausted all of our retry attempts while trying to send the payment, or we
547-
/// exhausted the [`Retry::Timeout`] if the user set one. If at any point a retry
548-
/// attempt failed while being forwarded along the path, an [`Event::PaymentPathFailed`] will
546+
#[cfg_attr(feature = "std", doc = "We exhausted all of our retry attempts while trying to send the payment, or we")]
547+
#[cfg_attr(feature = "std", doc = "exhausted the [`Retry::Timeout`] if the user set one.")]
548+
#[cfg_attr(not(feature = "std"), doc = "We exhausted all of our retry attempts while trying to send the payment.")]
549+
/// If at any point a retry attempt failed while being forwarded along the path, an [`Event::PaymentPathFailed`] will
549550
/// have come before this.
550-
///
551-
/// [`Retry::Timeout`]: crate::ln::channelmanager::Retry::Timeout
551+
#[cfg_attr(feature = "std", doc = "")]
552+
#[cfg_attr(feature = "std", doc = "[`Retry::Timeout`]: crate::ln::channelmanager::Retry::Timeout")]
552553
RetriesExhausted,
553554
/// The payment expired while retrying, based on the provided
554555
/// [`PaymentParameters::expiry_time`].

lightning/src/ln/invoice_utils.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ use core::iter::Iterator;
6161
/// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
6262
/// [`PhantomRouteHints::channels`]: crate::ln::channelmanager::PhantomRouteHints::channels
6363
/// [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA
64-
///
65-
/// This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
66-
/// available and the current time is supplied by the caller.
64+
#[cfg_attr(feature = "std", doc = "")]
65+
#[cfg_attr(feature = "std", doc = "This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not available and the current time is supplied by the caller.")]
6766
pub fn create_phantom_invoice<ES: Deref, NS: Deref, L: Deref>(
6867
amt_msat: Option<u64>, payment_hash: Option<PaymentHash>, description: String,
6968
invoice_expiry_delta_secs: u32, phantom_route_hints: Vec<PhantomRouteHints>, entropy_source: ES,
@@ -117,9 +116,8 @@ where
117116
/// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
118117
/// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
119118
/// [`PhantomRouteHints::channels`]: crate::ln::channelmanager::PhantomRouteHints::channels
120-
///
121-
/// This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
122-
/// available and the current time is supplied by the caller.
119+
#[cfg_attr(feature = "std", doc = "")]
120+
#[cfg_attr(feature = "std", doc = "This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not available and the current time is supplied by the caller.")]
123121
pub fn create_phantom_invoice_with_description_hash<ES: Deref, NS: Deref, L: Deref>(
124122
amt_msat: Option<u64>, payment_hash: Option<PaymentHash>, invoice_expiry_delta_secs: u32,
125123
description_hash: Sha256, phantom_route_hints: Vec<PhantomRouteHints>, entropy_source: ES,
@@ -399,9 +397,12 @@ where
399397
)
400398
}
401399

402-
/// See [`create_invoice_from_channelmanager_with_description_hash`]
403-
/// This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
404-
/// available and the current time is supplied by the caller.
400+
/// Utility to construct an invoice. Generally, unless you want to do something like a custom
401+
/// `cltv_expiry`, this is what you should be using to create an invoice.
402+
#[cfg_attr(feature = "std", doc = "")]
403+
#[cfg_attr(feature = "std", doc = "See [`create_invoice_from_channelmanager_with_description_hash`] for more information.")]
404+
#[cfg_attr(feature = "std", doc = "")]
405+
#[cfg_attr(feature = "std", doc = "This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not available and the current time is supplied by the caller.")]
405406
pub fn create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref>(
406407
channelmanager: &ChannelManager<M, T, ES, NS, SP, F, R, L>, node_signer: NS, logger: L,
407408
network: Currency, amt_msat: Option<u64>, description_hash: Sha256,
@@ -424,9 +425,12 @@ pub fn create_invoice_from_channelmanager_with_description_hash_and_duration_sin
424425
)
425426
}
426427

427-
/// See [`create_invoice_from_channelmanager`]
428-
/// This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not
429-
/// available and the current time is supplied by the caller.
428+
/// Utility to construct an invoice. Generally, unless you want to do something like a custom
429+
/// `cltv_expiry`, this is what you should be using to create an invoice.
430+
#[cfg_attr(feature = "std", doc = "")]
431+
#[cfg_attr(feature = "std", doc = "See [`create_invoice_from_channelmanager`] for more information.")]
432+
#[cfg_attr(feature = "std", doc = "")]
433+
#[cfg_attr(feature = "std", doc = "This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not available and the current time is supplied by the caller.")]
430434
pub fn create_invoice_from_channelmanager_and_duration_since_epoch<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, L: Deref>(
431435
channelmanager: &ChannelManager<M, T, ES, NS, SP, F, R, L>, node_signer: NS, logger: L,
432436
network: Currency, amt_msat: Option<u64>, description: String, duration_since_epoch: Duration,

lightning/src/ln/msgs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub enum DecodeError {
8787
ShortRead,
8888
/// A length descriptor in the packet didn't describe the later data correctly.
8989
BadLengthDescriptor,
90-
/// Error from [`std::io`].
90+
/// Error from [`crate::io`].
9191
Io(io::ErrorKind),
9292
/// The message included zlib-compressed values, which we don't support.
9393
UnsupportedCompression,

lightning/src/ln/outbound_payment.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,9 @@ impl_writeable_tlv_based_enum_legacy!(StaleExpiration,
438438
/// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed
439439
#[derive(Clone, Debug, PartialEq, Eq)]
440440
pub enum RetryableSendFailure {
441-
/// The provided [`PaymentParameters::expiry_time`] indicated that the payment has expired. Note
442-
/// that this error is *not* caused by [`Retry::Timeout`].
441+
/// The provided [`PaymentParameters::expiry_time`] indicated that the payment has expired.
442+
#[cfg_attr(feature = "std", doc = "")]
443+
#[cfg_attr(feature = "std", doc = "Note that this error is *not* caused by [`Retry::Timeout`].")]
443444
///
444445
/// [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time
445446
PaymentExpired,

lightning/src/offers/invoice_macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ macro_rules! invoice_builder_methods_common { (
1616
#[doc = concat!("Sets the [`", stringify!($invoice_type), "::relative_expiry`]")]
1717
#[doc = concat!("as seconds since [`", stringify!($invoice_type), "::created_at`].")]
1818
#[doc = "Any expiry that has already passed is valid and can be checked for using"]
19-
#[doc = concat!("[`", stringify!($invoice_type), "::is_expired`].")]
19+
#[cfg_attr(feature = "std", doc = concat!("[`", stringify!($invoice_type), "::is_expired`]."))]
2020
///
2121
/// Successive calls to this method will override the previous setting.
2222
pub fn relative_expiry($($self_mut)* $self: $self_type, relative_expiry_secs: u32) -> $return_type {

lightning/src/offers/invoice_request.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -615,12 +615,11 @@ pub struct VerifiedInvoiceRequest {
615615

616616
/// Keys used for signing a [`Bolt12Invoice`] if they can be derived.
617617
///
618-
/// If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call
619-
/// [`respond_with`].
620-
///
618+
#[cfg_attr(feature = "std", doc = "If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call [`respond_with`].")]
619+
#[cfg_attr(feature = "std", doc = "")]
621620
/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
622-
/// [`respond_using_derived_keys`]: Self::respond_using_derived_keys
623-
/// [`respond_with`]: Self::respond_with
621+
#[cfg_attr(feature = "std", doc = "[`respond_using_derived_keys`]: Self::respond_using_derived_keys")]
622+
#[cfg_attr(feature = "std", doc = "[`respond_with`]: Self::respond_with")]
624623
pub keys: Option<Keypair>,
625624
}
626625

@@ -719,8 +718,8 @@ macro_rules! invoice_request_respond_with_explicit_signing_pubkey_methods { (
719718
/// Creates an [`InvoiceBuilder`] for the request with the given required fields.
720719
///
721720
/// Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after
722-
/// `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for non-`std` builds
723-
/// where [`std::time::SystemTime`] is not available.
721+
/// `created_at`, which is used to set [`Bolt12Invoice::created_at`].
722+
#[cfg_attr(feature = "std", doc = "Useful for non-`std` builds where [`std::time::SystemTime`] is not available.")]
724723
///
725724
/// The caller is expected to remember the preimage of `payment_hash` in order to claim a payment
726725
/// for the invoice.

lightning/src/offers/offer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ macro_rules! offer_builder_methods { (
316316
$return_value
317317
}
318318

319-
/// Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has
320-
/// already passed is valid and can be checked for using [`Offer::is_expired`].
319+
/// Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch.
320+
#[cfg_attr(feature = "std", doc = "Any expiry that has already passed is valid and can be checked for using [`Offer::is_expired`].")]
321321
///
322322
/// Successive calls to this method will override the previous setting.
323323
pub fn absolute_expiry($($self_mut)* $self: $self_type, absolute_expiry: Duration) -> $return_type {

lightning/src/offers/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub enum Bolt12ParseError {
135135
/// Error when interpreting a TLV stream as a specific type.
136136
#[derive(Clone, Debug, PartialEq)]
137137
pub enum Bolt12SemanticError {
138-
/// The current [`std::time::SystemTime`] is past the offer or invoice's expiration.
138+
/// The current system time is past the offer or invoice's expiration.
139139
AlreadyExpired,
140140
/// The provided chain hash does not correspond to a supported chain.
141141
UnsupportedChain,

lightning/src/offers/refund.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ macro_rules! refund_builder_methods { (
231231
$return_value
232232
}
233233

234-
/// Sets the [`Refund::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has
235-
/// already passed is valid and can be checked for using [`Refund::is_expired`].
234+
/// Sets the [`Refund::absolute_expiry`] as seconds since the Unix epoch.
235+
#[cfg_attr(feature = "std", doc = "Any expiry that has already passed is valid and can be checked for using [`Refund::is_expired`].")]
236236
///
237237
/// Successive calls to this method will override the previous setting.
238238
pub fn absolute_expiry($($self_mut)* $self: $self_type, absolute_expiry: Duration) -> $return_type {
@@ -545,8 +545,8 @@ macro_rules! respond_with_explicit_signing_pubkey_methods { ($self: ident, $buil
545545
/// Creates an [`InvoiceBuilder`] for the refund with the given required fields.
546546
///
547547
/// Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after
548-
/// `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for non-`std` builds
549-
/// where [`std::time::SystemTime`] is not available.
548+
/// `created_at`, which is used to set [`Bolt12Invoice::created_at`].
549+
#[cfg_attr(feature = "std", doc = "Useful for non-`std` builds where [`std::time::SystemTime`] is not available.")]
550550
///
551551
/// The caller is expected to remember the preimage of `payment_hash` in order to
552552
/// claim a payment for the invoice.

lightning/src/routing/gossip.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,9 +2121,9 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
21212121
///
21222122
/// This method will also cause us to stop tracking removed nodes and channels if they have been
21232123
/// in the map for a while so that these can be resynced from gossip in the future.
2124-
///
2125-
/// This function takes the current unix time as an argument. For users with the `std` feature
2126-
/// enabled, [`NetworkGraph::remove_stale_channels_and_tracking`] may be preferable.
2124+
#[cfg_attr(feature = "std", doc = "")]
2125+
#[cfg_attr(feature = "std", doc = "This function takes the current unix time as an argument. For users with the `std` feature")]
2126+
#[cfg_attr(feature = "std", doc = "enabled, [`NetworkGraph::remove_stale_channels_and_tracking`] may be preferable.")]
21272127
pub fn remove_stale_channels_and_tracking_with_time(&self, current_time_unix: u64) {
21282128
let mut channels = self.channels.write().unwrap();
21292129
// Time out if we haven't received an update in at least 14 days.

lightning/src/util/ser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ use crate::util::string::UntrustedString;
5050
/// serialization buffer size
5151
pub const MAX_BUF_SIZE: usize = 64 * 1024;
5252

53-
/// A simplified version of [`std::io::Write`] that exists largely for backwards compatibility.
54-
/// An impl is provided for any type that also impls [`std::io::Write`].
53+
/// A simplified version of `std::io::Write` that exists largely for backwards compatibility.
54+
/// An impl is provided for any type that also impls `std::io::Write`.
5555
///
5656
/// This is not exported to bindings users as we only export serialization to/from byte arrays instead
5757
pub trait Writer {
@@ -173,7 +173,7 @@ impl Writer for LengthCalculatingWriter {
173173
}
174174
}
175175

176-
/// Essentially [`std::io::Take`] but a bit simpler and with a method to walk the underlying stream
176+
/// Essentially `std::io::Take` but a bit simpler and with a method to walk the underlying stream
177177
/// forward to ensure we always consume exactly the fixed length specified.
178178
///
179179
/// This is not exported to bindings users as manual TLV building is not currently supported in bindings

lightning/src/util/ser_macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,7 @@ macro_rules! _init_and_read_tlv_stream {
872872
///
873873
/// [`Readable`]: crate::util::ser::Readable
874874
/// [`Writeable`]: crate::util::ser::Writeable
875+
/// [`Vec`]: crate::prelude::Vec
875876
#[macro_export]
876877
macro_rules! impl_writeable_tlv_based {
877878
($st: ident, {$(($type: expr, $field: ident, $fieldty: tt)),* $(,)*}) => {

lightning/src/util/wakers.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,10 @@ macro_rules! define_callback { ($($bounds: path),*) => {
9797
/// A callback which is called when a [`Future`] completes.
9898
///
9999
/// Note that this MUST NOT call back into LDK directly, it must instead schedule actions to be
100-
/// taken later. Rust users should use the [`std::future::Future`] implementation for [`Future`]
101-
/// instead.
102-
///
103-
/// Note that the [`std::future::Future`] implementation may only work for runtimes which schedule
104-
/// futures when they receive a wake, rather than immediately executing them.
100+
/// taken later.
101+
#[cfg_attr(feature = "std", doc = "Rust users should use the [`std::future::Future`] implementation for [`Future`] instead.")]
102+
#[cfg_attr(feature = "std", doc = "")]
103+
#[cfg_attr(feature = "std", doc = "Note that the [`std::future::Future`] implementation may only work for runtimes which schedule futures when they receive a wake, rather than immediately executing them.")]
105104
pub trait FutureCallback : $($bounds +)* {
106105
/// The method which is called.
107106
fn call(&self);

0 commit comments

Comments
 (0)