Skip to content

Commit 2354e2c

Browse files
ser: support LengthLimitedRead in impl_writeable_tlv_based_enum
When introducing the LengthLimitedRead trait in [1], for some serialization macros we need some temporary workaround to avoid that we have the following compilation error error[E0277]: the trait bound `Bolt12Invoice: Readable` is not satisfied --> lightning/src/util/ser_macros.rs:1243:35 | 1243 | Ok($st::$tuple_variant_name($crate::util::ser::Readable::read(reader)?)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Readable` is not implemented for `Bolt12Invoice` | ::: lightning/src/events/mod.rs:2463:1 | 2463 | / impl_writeable_tlv_based_enum_legacy!(PaidInvoice, 2464 | | ; 2465 | | (0, Bolt12Invoice), 2466 | | (2, StaticInvoice) 2467 | | ); | |_- in this macro invocation | = help: the following other types implement trait `Readable`: () (A, B) (A, B, C) (A, B, C, D) (A, B, C, D, E) (A, B, C, D, E, F) (A, B, C, D, E, F, G) AnnouncementSigsState and 200 others = note: this error originates in the macro `impl_writeable_tlv_based_enum_legacy` (in Nightly builds, run with -Z macro-backtrace for more info) This is a temporary workaround to avoid introducing a big refactoring right now. [1] lightningdevkit#3640 Co-Developed-by: @valentinewallace Suggested-by: @valentinewallace Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent 419776c commit 2354e2c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lightning/src/util/ser_macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ macro_rules! impl_writeable_tlv_based_enum {
12001200
$($tuple_variant_id => {
12011201
let length: $crate::util::ser::BigSize = $crate::util::ser::Readable::read(reader)?;
12021202
let mut s = $crate::util::ser::FixedLengthReader::new(reader, length.0);
1203-
let res = $crate::util::ser::Readable::read(&mut s)?;
1203+
let res = $crate::util::ser::LengthReadable::read_from_fixed_length_buffer(&mut s)?;
12041204
if s.bytes_remain() {
12051205
s.eat_remaining()?; // Return ShortRead if there's actually not enough bytes
12061206
return Err($crate::ln::msgs::DecodeError::InvalidValue);

0 commit comments

Comments
 (0)