@@ -522,8 +522,8 @@ macro_rules! write_ver_prefix {
522522 }
523523}
524524
525- /// Writes out a suffix to an object which contains potentially backwards-compatible, optional
526- /// fields which old nodes can happily ignore.
525+ /// Writes out a suffix to an object as a length-prefixed TLV stream which contains potentially
526+ /// backwards-compatible, optional fields which old nodes can happily ignore.
527527///
528528/// It is written out in TLV format and, as with all TLV fields, unknown even fields cause a
529529/// [`DecodeError::UnknownRequiredFeature`] error, with unknown odd fields ignored.
@@ -627,10 +627,28 @@ macro_rules! _init_and_read_tlv_fields {
627627}
628628
629629/// Implements [`Readable`]/[`Writeable`] for a struct storing it as a set of TLVs
630- /// If $fieldty is `required`, then $field is a required field that is not an Option nor a Vec.
631- /// If $fieldty is `option`, then $field is optional field.
632- /// if $fieldty is `vec_type`, then $field is a Vec, which needs to have its individual elements
633- /// serialized.
630+ /// If `$fieldty` is `required`, then `$field` is a required field that is not an Option nor a Vec.
631+ /// If `$fieldty` is `(default_value, $default)`, then `$field` will be set to `$default` if not present.
632+ /// If `$fieldty` is `option`, then `$field` is optional field.
633+ /// If `$fieldty` is `vec_type`, then `$field` is a Vec, which needs to have its individual elements serialized.
634+ ///
635+ /// For example,
636+ /// ```
637+ /// # use lightning::impl_writeable_tlv_based;
638+ /// struct LightningMessage {
639+ /// tlv_integer: u32,
640+ /// tlv_default_integer: u32,
641+ /// tlv_optional_integer: Option<u32>,
642+ /// tlv_vec_type_integer: Vec<u32>,
643+ /// }
644+ ///
645+ /// impl_writeable_tlv_based!(LightningMessage, {
646+ /// (0, tlv_integer, required),
647+ /// (1, tlv_default_integer, (default_value, 7)),
648+ /// (2, tlv_optional_integer, option),
649+ /// (3, tlv_vec_type_integer, vec_type),
650+ /// });
651+ /// ```
634652///
635653/// [`Readable`]: crate::util::ser::Readable
636654/// [`Writeable`]: crate::util::ser::Writeable
0 commit comments