]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Extract read/write variants from impl_for_vec
authorValentine Wallace <vwallace@protonmail.com>
Sun, 9 Apr 2023 20:51:55 +0000 (16:51 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Thu, 20 Apr 2023 14:14:17 +0000 (10:14 -0400)
We'll need to (de)serialize vecs of BlindedPaths differently based on whether
we're writing or reading

lightning/src/util/ser.rs

index 8056f3bed35569e952c6897a4b999b6e2bf3b1fd..566c74752d7dbd34ea3f65a185bf874e97c4cb23 100644 (file)
@@ -749,7 +749,7 @@ where T: Readable + Eq + Hash
 }
 
 // Vectors
-macro_rules! impl_for_vec {
+macro_rules! impl_writeable_for_vec {
        ($ty: ty $(, $name: ident)*) => {
                impl<$($name : Writeable),*> Writeable for Vec<$ty> {
                        #[inline]
@@ -761,7 +761,10 @@ macro_rules! impl_for_vec {
                                Ok(())
                        }
                }
-
+       }
+}
+macro_rules! impl_readable_for_vec {
+       ($ty: ty $(, $name: ident)*) => {
                impl<$($name : Readable),*> Readable for Vec<$ty> {
                        #[inline]
                        fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
@@ -777,6 +780,12 @@ macro_rules! impl_for_vec {
                }
        }
 }
+macro_rules! impl_for_vec {
+       ($ty: ty $(, $name: ident)*) => {
+               impl_writeable_for_vec!($ty $(, $name)*);
+               impl_readable_for_vec!($ty $(, $name)*);
+       }
+}
 
 impl Writeable for Vec<u8> {
        #[inline]