Merge pull request #1748 from valentinewallace/2022-10-custom-oms
[rust-lightning] / lightning / src / util / ser.rs
index 3de03ea5a0d5efd93b4c3a22e4d88845656dbf23..3b82da8446da033d5d579cf7ec5a7d87e85225f8 100644 (file)
@@ -269,6 +269,15 @@ impl<T: Readable> MaybeReadable for T {
        }
 }
 
+/// A trait that various rust-lightning types implement allowing them to (maybe) be read in from a
+/// Read, given some additional set of arguments which is required to deserialize.
+///
+/// (C-not exported) as we only export serialization to/from byte arrays instead
+pub trait MaybeReadableArgs<P> {
+       /// Reads a Self in from the given Read
+       fn read<R: Read>(reader: &mut R, params: P) -> Result<Option<Self>, DecodeError> where Self: Sized;
+}
+
 pub(crate) struct OptionDeserWrapper<T: Readable>(pub Option<T>);
 impl<T: Readable> Readable for OptionDeserWrapper<T> {
        #[inline]