Skip to content

Commit d83390c

Browse files
committed
Document some TLV write/read formats
While we don't want to publicly document these and support them for downstream crates, documenting them internally is useful.
1 parent 907ea20 commit d83390c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lightning/src/util/ser_macros.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,21 @@
1313
//! [`Readable`]: crate::util::ser::Readable
1414
//! [`Writeable`]: crate::util::ser::Writeable
1515
16+
// There are quite a few TLV serialization "types" which behave differently. We currently only
17+
// publicly document the `optional` and `required` types, not supporting anything else publicly and
18+
// changing them at will.
19+
//
20+
// Some of the other types include:
21+
// * (default_value, $default) - reads optionally, reading $default if no TLV is present
22+
// * (static_value, $value) - ignores any TLVs, always using $value
23+
// * required_vec - reads into a Vec without a length prefix, failing if no TLV is present.
24+
// * optional_vec - reads into an Option<Vec> without a length prefix, continuing if no TLV is
25+
// present. Writes from a Vec directly, only if any elements are present. Note
26+
// that the struct deserialization macros return a Vec, not an Option.
27+
// * upgradable_option - reads via MaybeReadable.
28+
// * upgradable_required - reads via MaybeReadable, requiring a TLV be present but may return None
29+
// if MaybeReadable::read() returns None.
30+
1631
/// Implements serialization for a single TLV record.
1732
/// This is exported for use by other exported macros, do not use directly.
1833
#[doc(hidden)]

0 commit comments

Comments
 (0)