@@ -41,7 +41,7 @@ macro_rules! _encode_tlv {
41
41
} ;
42
42
}
43
43
44
- /// Implements the TLVs serialization part in a Writeable implementation of a struct.
44
+ /// Implements the TLVs serialization part in a [` Writeable`] implementation of a struct.
45
45
///
46
46
/// This should be called inside a method which returns `Result<_, `[`io::Error`]`>`, such as
47
47
/// [`Writeable::write`]. It will only return an `Err` if the stream `Err`s or [`Writeable::write`]
@@ -75,6 +75,7 @@ macro_rules! _encode_tlv {
75
75
/// # }
76
76
/// ```
77
77
///
78
+ /// [`Writeable`]: crate::util::ser::Writeable
78
79
/// [`io::Error`]: crate::io::Error
79
80
/// [`Writeable::write`]: crate::util::ser::Writeable::write
80
81
/// [`Writer`]: crate::util::ser::Writer
@@ -107,8 +108,10 @@ macro_rules! encode_tlv_stream {
107
108
} }
108
109
}
109
110
110
- /// Adds the length of the serialized field to a LengthCalculatingWriter.
111
+ /// Adds the length of the serialized field to a [` LengthCalculatingWriter`] .
111
112
/// This is exported for use by other exported macros, do not use directly.
113
+ ///
114
+ /// [`LengthCalculatingWriter`]: crate::util::ser::LengthCalculatingWriter
112
115
#[ doc( hidden) ]
113
116
#[ macro_export]
114
117
macro_rules! _get_varint_length_prefixed_tlv_length {
@@ -134,7 +137,7 @@ macro_rules! _get_varint_length_prefixed_tlv_length {
134
137
} ;
135
138
}
136
139
137
- /// See the documentation of write_tlv_fields!() .
140
+ /// See the documentation of [` write_tlv_fields`] .
138
141
/// This is exported for use by other exported macros, do not use directly.
139
142
#[ doc( hidden) ]
140
143
#[ macro_export]
@@ -261,7 +264,7 @@ macro_rules! _decode_tlv {
261
264
} } ;
262
265
}
263
266
264
- /// Implements the TLVs deserialization part in a Readable implementation of a struct.
267
+ /// Implements the TLVs deserialization part in a [` Readable`] implementation of a struct.
265
268
///
266
269
/// This should be called inside a method which returns `Result<_, `[`DecodeError`]`>`, such as
267
270
/// [`Readable::read`]. It will either return an `Err` or ensure all `required` fields have been
@@ -293,6 +296,7 @@ macro_rules! _decode_tlv {
293
296
/// # }
294
297
/// ```
295
298
///
299
+ /// [`Readable`]: crate::util::ser::Readable
296
300
/// [`DecodeError`]: crate::ln::msgs::DecodeError
297
301
/// [`Readable::read`]: crate::util::ser::Readable::read
298
302
/// [`Read`]: crate::io::Read
@@ -308,9 +312,12 @@ macro_rules! decode_tlv_stream {
308
312
/// Similar to [`decode_tlv_stream`] with a custom TLV decoding capabilities.
309
313
///
310
314
/// `$decode_custom_tlv` is a closure that may be optionally provided to handle custom message types.
311
- /// If it is provided, it will be called with the custom type and the `FixedLengthReader` containing
315
+ /// If it is provided, it will be called with the custom type and the [ `FixedLengthReader`] containing
312
316
/// the message contents. It should return `Ok(true)` if the custom message is successfully parsed,
313
- /// `Ok(false)` if the message type is unknown, and `Err(DecodeError)` if parsing fails.
317
+ /// `Ok(false)` if the message type is unknown, and `Err(`[`DecodeError`]`)` if parsing fails.
318
+ ///
319
+ /// [`FixedLengthReader`]: crate::util::ser::FixedLengthReader
320
+ /// [`DecodeError`]: crate::ln::msgs::DecodeError
314
321
macro_rules! decode_tlv_stream_with_custom_tlv_decode {
315
322
( $stream: expr, { $( ( $type: expr, $field: ident, $fieldty: tt) ) ,* $( , ) * }
316
323
$( , $decode_custom_tlv: expr) ?) => { {
@@ -464,12 +471,14 @@ macro_rules! impl_writeable {
464
471
/// object.
465
472
/// $min_version_that_can_read_this is the minimum reader version which can understand this
466
473
/// serialized object. Previous versions will simply err with a
467
- /// DecodeError::UnknownVersion.
474
+ /// [` DecodeError::UnknownVersion`] .
468
475
///
469
476
/// Updates to either $this_version or $min_version_that_can_read_this should be included in
470
477
/// release notes.
471
478
///
472
479
/// Both version fields can be specific to this type of object.
480
+ ///
481
+ /// [`DecodeError::UnknownVersion`]: crate::ln::msgs::DecodeError::UnknownVersion
473
482
macro_rules! write_ver_prefix {
474
483
( $stream: expr, $this_version: expr, $min_version_that_can_read_this: expr) => {
475
484
$stream. write_all( & [ $this_version; 1 ] ) ?;
@@ -481,20 +490,22 @@ macro_rules! write_ver_prefix {
481
490
/// fields which old nodes can happily ignore.
482
491
///
483
492
/// It is written out in TLV format and, as with all TLV fields, unknown even fields cause a
484
- /// DecodeError::UnknownRequiredFeature error, with unknown odd fields ignored.
493
+ /// [` DecodeError::UnknownRequiredFeature`] error, with unknown odd fields ignored.
485
494
///
486
495
/// This is the preferred method of adding new fields that old nodes can ignore and still function
487
496
/// correctly.
497
+ ///
498
+ /// [`DecodeError::UnknownRequiredFeature`]: crate::ln::msgs::DecodeError::UnknownRequiredFeature
488
499
#[ macro_export]
489
500
macro_rules! write_tlv_fields {
490
501
( $stream: expr, { $( ( $type: expr, $field: expr, $fieldty: tt) ) ,* $( , ) * } ) => {
491
502
$crate:: _encode_varint_length_prefixed_tlv!( $stream, { $( ( $type, $field, $fieldty) ) ,* } )
492
503
}
493
504
}
494
505
495
- /// Reads a prefix added by write_ver_prefix!() , above. Takes the current version of the
506
+ /// Reads a prefix added by [` write_ver_prefix`] , above. Takes the current version of the
496
507
/// serialization logic for this object. This is compared against the
497
- /// $min_version_that_can_read_this added by write_ver_prefix!() .
508
+ /// $min_version_that_can_read_this added by [` write_ver_prefix`] .
498
509
macro_rules! read_ver_prefix {
499
510
( $stream: expr, $this_version: expr) => { {
500
511
let ver: u8 = Readable :: read( $stream) ?;
@@ -506,7 +517,7 @@ macro_rules! read_ver_prefix {
506
517
} }
507
518
}
508
519
509
- /// Reads a suffix added by write_tlv_fields!() .
520
+ /// Reads a suffix added by [` write_tlv_fields`] .
510
521
#[ macro_export]
511
522
macro_rules! read_tlv_fields {
512
523
( $stream: expr, { $( ( $type: expr, $field: ident, $fieldty: tt) ) ,* $( , ) * } ) => { {
@@ -570,11 +581,14 @@ macro_rules! _init_and_read_tlv_fields {
570
581
}
571
582
}
572
583
573
- /// Implements Readable/ Writeable for a struct storing it as a set of TLVs
584
+ /// Implements [` Readable`]/[` Writeable`] for a struct storing it as a set of TLVs
574
585
/// If $fieldty is `required`, then $field is a required field that is not an Option nor a Vec.
575
586
/// If $fieldty is `option`, then $field is optional field.
576
587
/// if $fieldty is `vec_type`, then $field is a Vec, which needs to have its individual elements
577
588
/// serialized.
589
+ ///
590
+ /// [`Readable`]: crate::util::ser::Readable
591
+ /// [`Writeable`]: crate::util::ser::Writeable
578
592
#[ macro_export]
579
593
macro_rules! impl_writeable_tlv_based {
580
594
( $st: ident, { $( ( $type: expr, $field: ident, $fieldty: tt) ) ,* $( , ) * } ) => {
@@ -717,13 +731,18 @@ macro_rules! _impl_writeable_tlv_based_enum_common {
717
731
}
718
732
}
719
733
720
- /// Implement MaybeReadable and Writeable for an enum, with struct variants stored as TLVs and
734
+ /// Implement [` MaybeReadable`] and [` Writeable`] for an enum, with struct variants stored as TLVs and
721
735
/// tuple variants stored directly.
722
736
///
723
- /// This is largely identical to `impl_writeable_tlv_based_enum`, except that odd variants will
724
- /// return `Ok(None)` instead of `Err(UnknownRequiredFeature)`. It should generally be preferred
725
- /// when `MaybeReadable` is practical instead of just `Readable` as it provides an upgrade path for
737
+ /// This is largely identical to [ `impl_writeable_tlv_based_enum`] , except that odd variants will
738
+ /// return `Ok(None)` instead of `Err(`[`DecodeError:: UnknownRequiredFeature`]` )`. It should generally be preferred
739
+ /// when [ `MaybeReadable`] is practical instead of just [ `Readable`] as it provides an upgrade path for
726
740
/// new variants to be added which are simply ignored by existing clients.
741
+ ///
742
+ /// [`MaybeReadable`]: crate::util::ser::MaybeReadable
743
+ /// [`Writeable`]: crate::util::ser::Writeable
744
+ /// [`DecodeError::UnknownRequiredFeature`]: crate::ln::msgs::DecodeError::UnknownRequiredFeature
745
+ /// [`Readable`]: crate::util::ser::Readable
727
746
macro_rules! impl_writeable_tlv_based_enum_upgradable {
728
747
( $st: ident, $( ( $variant_id: expr, $variant_name: ident) =>
729
748
{ $( ( $type: expr, $field: ident, $fieldty: tt) ) ,* $( , ) * }
@@ -765,7 +784,7 @@ macro_rules! impl_writeable_tlv_based_enum_upgradable {
765
784
}
766
785
}
767
786
768
- /// Implement Readable and Writeable for an enum, with struct variants stored as TLVs and tuple
787
+ /// Implement [` Readable`] and [` Writeable`] for an enum, with struct variants stored as TLVs and tuple
769
788
/// variants stored directly.
770
789
/// The format is, for example
771
790
/// impl_writeable_tlv_based_enum!(EnumName,
@@ -774,7 +793,11 @@ macro_rules! impl_writeable_tlv_based_enum_upgradable {
774
793
/// (2, TupleVariantA), (3, TupleVariantB),
775
794
/// );
776
795
/// The type is written as a single byte, followed by any variant data.
777
- /// Attempts to read an unknown type byte result in DecodeError::UnknownRequiredFeature.
796
+ /// Attempts to read an unknown type byte result in [`DecodeError::UnknownRequiredFeature`].
797
+ ///
798
+ /// [`Readable`]: crate::util::ser::Readable
799
+ /// [`Writeable`]: crate::util::ser::Writeable
800
+ /// [`DecodeError::UnknownRequiredFeature`]: crate::ln::msgs::DecodeError::UnknownRequiredFeature
778
801
macro_rules! impl_writeable_tlv_based_enum {
779
802
( $st: ident, $( ( $variant_id: expr, $variant_name: ident) =>
780
803
{ $( ( $type: expr, $field: ident, $fieldty: tt) ) ,* $( , ) * }
0 commit comments