@@ -457,6 +457,35 @@ macro_rules! _decode_tlv_stream_range {
457
457
} }
458
458
}
459
459
460
+ /// Implements [`Readable`]/[`Writeable`] for a message struct that may include non-TLV and
461
+ /// TLV-encoded parts.
462
+ ///
463
+ /// This is useful to implement a [`CustomMessageReader`].
464
+ ///
465
+ /// If `$fieldty` is `required`, then `$tlvfield` is a required field that is not an [`Option`] nor a [`Vec`].
466
+ /// If `$fieldty` is `(default_value, $default)`, then `$tlvfield` will be set to `$default` if not present.
467
+ /// If `$fieldty` is `option`, then `$tlvfield` is optional field.
468
+ /// If `$fieldty` is `vec_type`, then `$tlvfield` is a [`Vec`], which needs to have its individual elements serialized.
469
+ ///
470
+ /// For example,
471
+ /// ```
472
+ /// # use lightning::impl_writeable_msg;
473
+ /// impl_writeable_msg!(MyCustomMessage, {
474
+ /// field_1,
475
+ /// field_2,
476
+ /// field_3,
477
+ /// }{
478
+ /// (0, tlv_integer, required),
479
+ /// (1, tlv_default_integer, (default_value, 7)),
480
+ /// (2, tlv_optional_integer, option),
481
+ /// (3, tlv_vec_type_integer, vec_type),
482
+ /// });
483
+ /// ```
484
+ ///
485
+ /// [`Readable`]: crate::util::ser::Readable
486
+ /// [`Writeable`]: crate::util::ser::Writeable
487
+ /// [`CustomMessageReader`]: crate::ln::wire::CustomMessageReader
488
+ #[ macro_export]
460
489
macro_rules! impl_writeable_msg {
461
490
( $st: ident, { $( $field: ident) ,* $( , ) * } , { $( ( $type: expr, $tlvfield: ident, $fieldty: tt) ) ,* $( , ) * } ) => {
462
491
impl $crate:: util:: ser:: Writeable for $st {
@@ -642,10 +671,10 @@ macro_rules! _init_and_read_tlv_fields {
642
671
}
643
672
644
673
/// Implements [`Readable`]/[`Writeable`] for a struct storing it as a set of TLVs
645
- /// If `$fieldty` is `required`, then `$field` is a required field that is not an Option nor a Vec.
674
+ /// If `$fieldty` is `required`, then `$field` is a required field that is not an [` Option`] nor a [` Vec`] .
646
675
/// If `$fieldty` is `(default_value, $default)`, then `$field` will be set to `$default` if not present.
647
676
/// If `$fieldty` is `option`, then `$field` is optional field.
648
- /// If `$fieldty` is `vec_type`, then `$field` is a Vec, which needs to have its individual elements serialized.
677
+ /// If `$fieldty` is `vec_type`, then `$field` is a [` Vec`] , which needs to have its individual elements serialized.
649
678
///
650
679
/// For example,
651
680
/// ```
0 commit comments