Use u8 for TLV type when writing and reading our own structs
[rust-lightning] / lightning / src / util / ser.rs
index 26bc79231368ab95f38b007ff76b7d784b5d22bd..af67dca799dbde7194ed5b78acc1df809743e5a4 100644 (file)
@@ -249,6 +249,20 @@ impl<T: Readable> Readable for OptionDeserWrapper<T> {
        }
 }
 
+pub(crate) struct U8Wrapper(pub u8);
+impl Writeable for U8Wrapper {
+       #[inline(always)]
+       fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {
+               self.0.write(writer)
+       }
+}
+impl Readable for U8Wrapper {
+       #[inline(always)]
+       fn read<R: Read>(reader: &mut R) -> Result<U8Wrapper, DecodeError> {
+               Ok(Self(Readable::read(reader)?))
+       }
+}
+
 const MAX_ALLOC_SIZE: u64 = 64*1024;
 
 pub(crate) struct VecWriteWrapper<'a, T: Writeable>(pub &'a Vec<T>);