+/// A trait that various higher-level rust-lightning types implement allowing them to be read in
+/// from a Read given some additional set of arguments which is required to deserialize.
+pub trait ReadableArgs<R, P>
+ where Self: Sized,
+ R: Read
+{
+ /// Reads a Self in from the given Read
+ fn read(reader: &mut R, params: P) -> Result<Self, DecodeError>;
+}
+
+pub(crate) struct U48(pub u64);
+impl Writeable for U48 {
+ #[inline]
+ fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {
+ writer.write_all(&be48_to_array(self.0))
+ }
+}
+impl<R: Read> Readable<R> for U48 {
+ #[inline]
+ fn read(reader: &mut R) -> Result<U48, DecodeError> {
+ let mut buf = [0; 6];
+ reader.read_exact(&mut buf)?;
+ Ok(U48(slice_to_be48(&buf)))
+ }
+}
+