@@ -26,10 +26,10 @@ macro_rules! encode_tlv {
26
26
field. write( $stream) ?;
27
27
}
28
28
} ;
29
- ( $stream: expr, $type: expr, $field: expr, ( tlv_record , ( $fieldty: ty, $wrapper : ident) ) ) => {
30
- encode_tlv!( $stream, $type, $field. map( |f| $wrapper ( f) ) , option) ;
29
+ ( $stream: expr, $type: expr, $field: expr, ( option , encoding : ( $fieldty: ty, $encoding : ident) ) ) => {
30
+ encode_tlv!( $stream, $type, $field. map( |f| $encoding ( f) ) , option) ;
31
31
} ;
32
- ( $stream: expr, $type: expr, $field: expr, ( tlv_record , $fieldty: ty) ) => {
32
+ ( $stream: expr, $type: expr, $field: expr, ( option , encoding : $fieldty: ty) ) => {
33
33
encode_tlv!( $stream, $type, $field, option) ;
34
34
} ;
35
35
}
@@ -127,7 +127,7 @@ macro_rules! check_tlv_order {
127
127
( $last_seen_type: expr, $typ: expr, $type: expr, $field: ident, ( option: $trait: ident $( , $read_arg: expr) ?) ) => { {
128
128
// no-op
129
129
} } ;
130
- ( $last_seen_type: expr, $typ: expr, $type: expr, $field: ident, ( tlv_record , $fieldty : tt) ) => { {
130
+ ( $last_seen_type: expr, $typ: expr, $type: expr, $field: ident, ( option , encoding : $encoding : tt) ) => { {
131
131
// no-op
132
132
} } ;
133
133
}
@@ -159,7 +159,7 @@ macro_rules! check_missing_tlv {
159
159
( $last_seen_type: expr, $type: expr, $field: ident, ( option: $trait: ident $( , $read_arg: expr) ?) ) => { {
160
160
// no-op
161
161
} } ;
162
- ( $last_seen_type: expr, $type: expr, $field: ident, ( tlv_record , $fieldty : tt) ) => { {
162
+ ( $last_seen_type: expr, $type: expr, $field: ident, ( option , encoding : $encoding : tt) ) => { {
163
163
// no-op
164
164
} } ;
165
165
}
@@ -184,13 +184,13 @@ macro_rules! decode_tlv {
184
184
( $reader: expr, $field: ident, ( option: $trait: ident $( , $read_arg: expr) ?) ) => { {
185
185
$field = Some ( $trait:: read( & mut $reader $( , $read_arg) * ) ?) ;
186
186
} } ;
187
- ( $reader: expr, $field: ident, ( tlv_record , ( $fieldty: ty, $wrapper : ident) ) ) => { {
187
+ ( $reader: expr, $field: ident, ( option , encoding : ( $fieldty: ty, $encoding : ident) ) ) => { {
188
188
$field = {
189
- let field: $wrapper <$fieldty> = ser:: Readable :: read( & mut $reader) ?;
189
+ let field: $encoding <$fieldty> = ser:: Readable :: read( & mut $reader) ?;
190
190
Some ( field. into( ) )
191
191
} ;
192
192
} } ;
193
- ( $reader: expr, $field: ident, ( tlv_record , $fieldty: ty) ) => { {
193
+ ( $reader: expr, $field: ident, ( option , encoding : $fieldty: ty) ) => { {
194
194
decode_tlv!( $reader, $field, option) ;
195
195
} } ;
196
196
}
@@ -396,9 +396,6 @@ macro_rules! init_tlv_field_var {
396
396
( $field: ident, option) => {
397
397
let mut $field = None ;
398
398
} ;
399
- ( $field: ident, tlv_record) => {
400
- let mut $field = None ;
401
- } ;
402
399
}
403
400
404
401
/// Implements Readable/Writeable for a struct storing it as a set of TLVs
@@ -480,7 +477,7 @@ macro_rules! tlv_stream {
480
477
impl <' a> :: util:: ser:: Writeable for $nameref<' a> {
481
478
fn write<W : :: util:: ser:: Writer >( & self , writer: & mut W ) -> Result <( ) , $crate:: io:: Error > {
482
479
encode_tlv_stream!( writer, {
483
- $( ( $type, self . $field, ( tlv_record , $fieldty) ) ) ,*
480
+ $( ( $type, self . $field, ( option , encoding : $fieldty) ) ) ,*
484
481
} ) ;
485
482
Ok ( ( ) )
486
483
}
@@ -489,10 +486,10 @@ macro_rules! tlv_stream {
489
486
impl :: util:: ser:: Readable for $name {
490
487
fn read<R : $crate:: io:: Read >( reader: & mut R ) -> Result <Self , :: ln:: msgs:: DecodeError > {
491
488
$(
492
- init_tlv_field_var!( $field, tlv_record ) ;
489
+ init_tlv_field_var!( $field, option ) ;
493
490
) *
494
491
decode_tlv_stream!( reader, {
495
- $( ( $type, $field, ( tlv_record , $fieldty) ) ) ,*
492
+ $( ( $type, $field, ( option , encoding : $fieldty) ) ) ,*
496
493
} ) ;
497
494
498
495
Ok ( Self {
0 commit comments