From: Elias Rohrer Date: Mon, 25 Mar 2024 13:04:57 +0000 (+0100) Subject: Implement `Readable` for `Offer` X-Git-Tag: v0.0.124-beta~103^2~1 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=c13b6d814bfb5dd95f9e40f8ff07dd45c47a387e;p=rust-lightning Implement `Readable` for `Offer` When storing `Offer`s, it's useful for them to implement LDK's deserialization trait. --- diff --git a/lightning/src/offers/offer.rs b/lightning/src/offers/offer.rs index 762bc1f33..db910b5e1 100644 --- a/lightning/src/offers/offer.rs +++ b/lightning/src/offers/offer.rs @@ -966,6 +966,13 @@ impl OfferContents { } } +impl Readable for Offer { + fn read(reader: &mut R) -> Result { + let bytes: WithoutLength> = Readable::read(reader)?; + Self::try_from(bytes.0).map_err(|_| DecodeError::InvalidValue) + } +} + impl Writeable for Offer { fn write(&self, writer: &mut W) -> Result<(), io::Error> { WithoutLength(&self.bytes).write(writer)