@@ -391,6 +391,18 @@ macro_rules! init_tlv_field_var {
391
391
} ;
392
392
}
393
393
394
+ macro_rules! init_and_read_tlv_fields {
395
+ ( $reader: ident, { $( ( $type: expr, $field: ident, $fieldty: tt) ) ,* $( , ) * } ) => {
396
+ $(
397
+ init_tlv_field_var!( $field, $fieldty) ;
398
+ ) *
399
+
400
+ read_tlv_fields!( $reader, {
401
+ $( ( $type, $field, $fieldty) ) ,*
402
+ } ) ;
403
+ }
404
+ }
405
+
394
406
/// Implements Readable/Writeable for a struct storing it as a set of TLVs
395
407
/// If $fieldty is `required`, then $field is a required field that is not an Option nor a Vec.
396
408
/// If $fieldty is `option`, then $field is optional field.
@@ -425,12 +437,10 @@ macro_rules! impl_writeable_tlv_based {
425
437
426
438
impl $crate:: util:: ser:: Readable for $st {
427
439
fn read<R : $crate:: io:: Read >( reader: & mut R ) -> Result <Self , $crate:: ln:: msgs:: DecodeError > {
428
- $(
429
- init_tlv_field_var!( $field, $fieldty) ;
430
- ) *
431
- read_tlv_fields!( reader, {
440
+ init_and_read_tlv_fields!( reader, {
432
441
$( ( $type, $field, $fieldty) ) ,*
433
442
} ) ;
443
+
434
444
Ok ( Self {
435
445
$(
436
446
$field: init_tlv_based_struct_field!( $field, $fieldty)
0 commit comments