From: Valentine Wallace Date: Mon, 17 Oct 2022 20:05:32 +0000 (-0400) Subject: ser: Add MaybeReadableArgs trait X-Git-Tag: v0.0.112~6^2~7 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=a40e32b197895812e86eb479ff9e59c05875f871;p=rust-lightning 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. --- 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]