Skip to content

Commit 697f37d

Browse files
authored
Merge pull request #2091 from tnull/2023-03-expose-impl-writeable-tlv-based-enum-common
2 parents 23c1b46 + 5af4076 commit 697f37d

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lightning/src/util/ser_macros.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,8 @@ macro_rules! tlv_record_ref_type {
874874
($type:ty) => { &'a $type };
875875
}
876876

877+
#[doc(hidden)]
878+
#[macro_export]
877879
macro_rules! _impl_writeable_tlv_based_enum_common {
878880
($st: ident, $(($variant_id: expr, $variant_name: ident) =>
879881
{$(($type: expr, $field: ident, $fieldty: tt)),* $(,)*}
@@ -885,7 +887,7 @@ macro_rules! _impl_writeable_tlv_based_enum_common {
885887
$($st::$variant_name { $(ref $field),* } => {
886888
let id: u8 = $variant_id;
887889
id.write(writer)?;
888-
write_tlv_fields!(writer, {
890+
$crate::write_tlv_fields!(writer, {
889891
$(($type, *$field, $fieldty)),*
890892
});
891893
}),*
@@ -923,7 +925,7 @@ macro_rules! impl_writeable_tlv_based_enum {
923925
{$(($type: expr, $field: ident, $fieldty: tt)),* $(,)*}
924926
),* $(,)*;
925927
$(($tuple_variant_id: expr, $tuple_variant_name: ident)),* $(,)*) => {
926-
_impl_writeable_tlv_based_enum_common!($st,
928+
$crate::_impl_writeable_tlv_based_enum_common!($st,
927929
$(($variant_id, $variant_name) => {$(($type, $field, $fieldty)),*}),*;
928930
$(($tuple_variant_id, $tuple_variant_name)),*);
929931

@@ -935,12 +937,12 @@ macro_rules! impl_writeable_tlv_based_enum {
935937
// Because read_tlv_fields creates a labeled loop, we cannot call it twice
936938
// in the same function body. Instead, we define a closure and call it.
937939
let f = || {
938-
_init_and_read_tlv_fields!(reader, {
940+
$crate::_init_and_read_tlv_fields!(reader, {
939941
$(($type, $field, $fieldty)),*
940942
});
941943
Ok($st::$variant_name {
942944
$(
943-
$field: _init_tlv_based_struct_field!($field, $fieldty)
945+
$field: $crate::_init_tlv_based_struct_field!($field, $fieldty)
944946
),*
945947
})
946948
};
@@ -977,7 +979,7 @@ macro_rules! impl_writeable_tlv_based_enum_upgradable {
977979
),* $(,)*
978980
$(;
979981
$(($tuple_variant_id: expr, $tuple_variant_name: ident)),* $(,)*)*) => {
980-
_impl_writeable_tlv_based_enum_common!($st,
982+
$crate::_impl_writeable_tlv_based_enum_common!($st,
981983
$(($variant_id, $variant_name) => {$(($type, $field, $fieldty)),*}),*;
982984
$($(($tuple_variant_id, $tuple_variant_name)),*)*);
983985

@@ -989,12 +991,12 @@ macro_rules! impl_writeable_tlv_based_enum_upgradable {
989991
// Because read_tlv_fields creates a labeled loop, we cannot call it twice
990992
// in the same function body. Instead, we define a closure and call it.
991993
let f = || {
992-
_init_and_read_tlv_fields!(reader, {
994+
$crate::_init_and_read_tlv_fields!(reader, {
993995
$(($type, $field, $fieldty)),*
994996
});
995997
Ok(Some($st::$variant_name {
996998
$(
997-
$field: _init_tlv_based_struct_field!($field, $fieldty)
999+
$field: $crate::_init_tlv_based_struct_field!($field, $fieldty)
9981000
),*
9991001
}))
10001002
};

0 commit comments

Comments
 (0)