@@ -58,7 +58,7 @@ macro_rules! _check_encoded_tlv_order {
58
58
} ;
59
59
}
60
60
61
- /// Implements the TLVs serialization part in a Writeable implementation of a struct.
61
+ /// Implements the TLVs serialization part in a [` Writeable`] implementation of a struct.
62
62
///
63
63
/// This should be called inside a method which returns `Result<_, `[`io::Error`]`>`, such as
64
64
/// [`Writeable::write`]. It will only return an `Err` if the stream `Err`s or [`Writeable::write`]
@@ -92,6 +92,7 @@ macro_rules! _check_encoded_tlv_order {
92
92
/// # }
93
93
/// ```
94
94
///
95
+ /// [`Writeable`]: crate::util::ser::Writeable
95
96
/// [`io::Error`]: crate::io::Error
96
97
/// [`Writeable::write`]: crate::util::ser::Writeable::write
97
98
/// [`Writer`]: crate::util::ser::Writer
@@ -120,8 +121,10 @@ macro_rules! encode_tlv_stream {
120
121
} }
121
122
}
122
123
123
- /// Adds the length of the serialized field to a LengthCalculatingWriter.
124
+ /// Adds the length of the serialized field to a [` LengthCalculatingWriter`] .
124
125
/// This is exported for use by other exported macros, do not use directly.
126
+ ///
127
+ /// [`LengthCalculatingWriter`]: crate::util::ser::LengthCalculatingWriter
125
128
#[ doc( hidden) ]
126
129
#[ macro_export]
127
130
macro_rules! _get_varint_length_prefixed_tlv_length {
@@ -149,7 +152,7 @@ macro_rules! _get_varint_length_prefixed_tlv_length {
149
152
} ;
150
153
}
151
154
152
- /// See the documentation of write_tlv_fields!() .
155
+ /// See the documentation of [` write_tlv_fields`] .
153
156
/// This is exported for use by other exported macros, do not use directly.
154
157
#[ doc( hidden) ]
155
158
#[ macro_export]
@@ -291,7 +294,7 @@ macro_rules! _decode_tlv_stream_match_check {
291
294
( $val: ident, $type: expr, $fieldty: tt) => { $val == $type }
292
295
}
293
296
294
- /// Implements the TLVs deserialization part in a Readable implementation of a struct.
297
+ /// Implements the TLVs deserialization part in a [` Readable`] implementation of a struct.
295
298
///
296
299
/// This should be called inside a method which returns `Result<_, `[`DecodeError`]`>`, such as
297
300
/// [`Readable::read`]. It will either return an `Err` or ensure all `required` fields have been
@@ -323,6 +326,7 @@ macro_rules! _decode_tlv_stream_match_check {
323
326
/// # }
324
327
/// ```
325
328
///
329
+ /// [`Readable`]: crate::util::ser::Readable
326
330
/// [`DecodeError`]: crate::ln::msgs::DecodeError
327
331
/// [`Readable::read`]: crate::util::ser::Readable::read
328
332
/// [`Read`]: crate::io::Read
@@ -338,9 +342,12 @@ macro_rules! decode_tlv_stream {
338
342
/// Similar to [`decode_tlv_stream`] with a custom TLV decoding capabilities.
339
343
///
340
344
/// `$decode_custom_tlv` is a closure that may be optionally provided to handle custom message types.
341
- /// If it is provided, it will be called with the custom type and the `FixedLengthReader` containing
345
+ /// If it is provided, it will be called with the custom type and the [ `FixedLengthReader`] containing
342
346
/// the message contents. It should return `Ok(true)` if the custom message is successfully parsed,
343
- /// `Ok(false)` if the message type is unknown, and `Err(DecodeError)` if parsing fails.
347
+ /// `Ok(false)` if the message type is unknown, and `Err(`[`DecodeError`]`)` if parsing fails.
348
+ ///
349
+ /// [`FixedLengthReader`]: crate::util::ser::FixedLengthReader
350
+ /// [`DecodeError`]: crate::ln::msgs::DecodeError
344
351
macro_rules! decode_tlv_stream_with_custom_tlv_decode {
345
352
( $stream: expr, { $( ( $type: expr, $field: ident, $fieldty: tt) ) ,* $( , ) * }
346
353
$( , $decode_custom_tlv: expr) ?) => { {
@@ -494,12 +501,14 @@ macro_rules! impl_writeable {
494
501
/// object.
495
502
/// $min_version_that_can_read_this is the minimum reader version which can understand this
496
503
/// serialized object. Previous versions will simply err with a
497
- /// DecodeError::UnknownVersion.
504
+ /// [` DecodeError::UnknownVersion`] .
498
505
///
499
506
/// Updates to either $this_version or $min_version_that_can_read_this should be included in
500
507
/// release notes.
501
508
///
502
509
/// Both version fields can be specific to this type of object.
510
+ ///
511
+ /// [`DecodeError::UnknownVersion`]: crate::ln::msgs::DecodeError::UnknownVersion
503
512
macro_rules! write_ver_prefix {
504
513
( $stream: expr, $this_version: expr, $min_version_that_can_read_this: expr) => {
505
514
$stream. write_all( & [ $this_version; 1 ] ) ?;
@@ -511,20 +520,22 @@ macro_rules! write_ver_prefix {
511
520
/// fields which old nodes can happily ignore.
512
521
///
513
522
/// It is written out in TLV format and, as with all TLV fields, unknown even fields cause a
514
- /// DecodeError::UnknownRequiredFeature error, with unknown odd fields ignored.
523
+ /// [` DecodeError::UnknownRequiredFeature`] error, with unknown odd fields ignored.
515
524
///
516
525
/// This is the preferred method of adding new fields that old nodes can ignore and still function
517
526
/// correctly.
527
+ ///
528
+ /// [`DecodeError::UnknownRequiredFeature`]: crate::ln::msgs::DecodeError::UnknownRequiredFeature
518
529
#[ macro_export]
519
530
macro_rules! write_tlv_fields {
520
531
( $stream: expr, { $( ( $type: expr, $field: expr, $fieldty: tt) ) ,* $( , ) * } ) => {
521
532
$crate:: _encode_varint_length_prefixed_tlv!( $stream, { $( ( $type, $field, $fieldty) ) ,* } )
522
533
}
523
534
}
524
535
525
- /// Reads a prefix added by write_ver_prefix!() , above. Takes the current version of the
536
+ /// Reads a prefix added by [` write_ver_prefix`] , above. Takes the current version of the
526
537
/// serialization logic for this object. This is compared against the
527
- /// $min_version_that_can_read_this added by write_ver_prefix!() .
538
+ /// $min_version_that_can_read_this added by [` write_ver_prefix`] .
528
539
macro_rules! read_ver_prefix {
529
540
( $stream: expr, $this_version: expr) => { {
530
541
let ver: u8 = Readable :: read( $stream) ?;
@@ -536,7 +547,9 @@ macro_rules! read_ver_prefix {
536
547
} }
537
548
}
538
549
539
- /// Reads a suffix added by write_tlv_fields!().
550
+ /// Reads a suffix added by [`write_tlv_fields`].
551
+ ///
552
+ /// [`write_tlv_fields`]: crate::write_tlv_fields
540
553
#[ macro_export]
541
554
macro_rules! read_tlv_fields {
542
555
( $stream: expr, { $( ( $type: expr, $field: ident, $fieldty: tt) ) ,* $( , ) * } ) => { {
@@ -606,11 +619,14 @@ macro_rules! _init_and_read_tlv_fields {
606
619
}
607
620
}
608
621
609
- /// Implements Readable/ Writeable for a struct storing it as a set of TLVs
622
+ /// Implements [` Readable`]/[` Writeable`] for a struct storing it as a set of TLVs
610
623
/// If $fieldty is `required`, then $field is a required field that is not an Option nor a Vec.
611
624
/// If $fieldty is `option`, then $field is optional field.
612
625
/// if $fieldty is `vec_type`, then $field is a Vec, which needs to have its individual elements
613
626
/// serialized.
627
+ ///
628
+ /// [`Readable`]: crate::util::ser::Readable
629
+ /// [`Writeable`]: crate::util::ser::Writeable
614
630
#[ macro_export]
615
631
macro_rules! impl_writeable_tlv_based {
616
632
( $st: ident, { $( ( $type: expr, $field: ident, $fieldty: tt) ) ,* $( , ) * } ) => {
@@ -754,13 +770,18 @@ macro_rules! _impl_writeable_tlv_based_enum_common {
754
770
}
755
771
}
756
772
757
- /// Implement MaybeReadable and Writeable for an enum, with struct variants stored as TLVs and
773
+ /// Implement [` MaybeReadable`] and [` Writeable`] for an enum, with struct variants stored as TLVs and
758
774
/// tuple variants stored directly.
759
775
///
760
- /// This is largely identical to `impl_writeable_tlv_based_enum`, except that odd variants will
761
- /// return `Ok(None)` instead of `Err(UnknownRequiredFeature)`. It should generally be preferred
762
- /// when `MaybeReadable` is practical instead of just `Readable` as it provides an upgrade path for
776
+ /// This is largely identical to [ `impl_writeable_tlv_based_enum`] , except that odd variants will
777
+ /// return `Ok(None)` instead of `Err(`[`DecodeError:: UnknownRequiredFeature`]` )`. It should generally be preferred
778
+ /// when [ `MaybeReadable`] is practical instead of just [ `Readable`] as it provides an upgrade path for
763
779
/// new variants to be added which are simply ignored by existing clients.
780
+ ///
781
+ /// [`MaybeReadable`]: crate::util::ser::MaybeReadable
782
+ /// [`Writeable`]: crate::util::ser::Writeable
783
+ /// [`DecodeError::UnknownRequiredFeature`]: crate::ln::msgs::DecodeError::UnknownRequiredFeature
784
+ /// [`Readable`]: crate::util::ser::Readable
764
785
macro_rules! impl_writeable_tlv_based_enum_upgradable {
765
786
( $st: ident, $( ( $variant_id: expr, $variant_name: ident) =>
766
787
{ $( ( $type: expr, $field: ident, $fieldty: tt) ) ,* $( , ) * }
@@ -802,7 +823,7 @@ macro_rules! impl_writeable_tlv_based_enum_upgradable {
802
823
}
803
824
}
804
825
805
- /// Implement Readable and Writeable for an enum, with struct variants stored as TLVs and tuple
826
+ /// Implement [` Readable`] and [` Writeable`] for an enum, with struct variants stored as TLVs and tuple
806
827
/// variants stored directly.
807
828
/// The format is, for example
808
829
/// impl_writeable_tlv_based_enum!(EnumName,
@@ -811,7 +832,11 @@ macro_rules! impl_writeable_tlv_based_enum_upgradable {
811
832
/// (2, TupleVariantA), (3, TupleVariantB),
812
833
/// );
813
834
/// The type is written as a single byte, followed by any variant data.
814
- /// Attempts to read an unknown type byte result in DecodeError::UnknownRequiredFeature.
835
+ /// Attempts to read an unknown type byte result in [`DecodeError::UnknownRequiredFeature`].
836
+ ///
837
+ /// [`Readable`]: crate::util::ser::Readable
838
+ /// [`Writeable`]: crate::util::ser::Writeable
839
+ /// [`DecodeError::UnknownRequiredFeature`]: crate::ln::msgs::DecodeError::UnknownRequiredFeature
815
840
macro_rules! impl_writeable_tlv_based_enum {
816
841
( $st: ident, $( ( $variant_id: expr, $variant_name: ident) =>
817
842
{ $( ( $type: expr, $field: ident, $fieldty: tt) ) ,* $( , ) * }
0 commit comments