From a40e32b197895812e86eb479ff9e59c05875f871 Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Mon, 17 Oct 2022 16:05:32 -0400 Subject: [PATCH] ser: Add MaybeReadableArgs trait Useful in decoding a custom message, so (a) the message type can be provided to the handler and (b) None can be returned if the message type is unknown. Used in upcoming commit(s) to support custom onion messages. --- lightning/src/util/ser.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lightning/src/util/ser.rs b/lightning/src/util/ser.rs index 852aa8f15..6b17ec7ed 100644 --- a/lightning/src/util/ser.rs +++ b/lightning/src/util/ser.rs @@ -269,6 +269,15 @@ impl 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

{ + /// Reads a Self in from the given Read + fn read(reader: &mut R, params: P) -> Result, DecodeError> where Self: Sized; +} + pub(crate) struct OptionDeserWrapper(pub Option); impl Readable for OptionDeserWrapper { #[inline] -- 2.39.5