X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fwire.rs;h=d3cc257f5a6b18cb1776475b4fec69949521e1d6;hb=7c4dfad4fe97c9d8bc37c38e15b9dab95f27e37a;hp=4caf3543b0f9f02e5ec3b650c8c9a82fa9cc861c;hpb=eb46f477f4b2459731e78c23423415cde278be09;p=rust-lightning diff --git a/lightning/src/ln/wire.rs b/lightning/src/ln/wire.rs index 4caf3543..d3cc257f 100644 --- a/lightning/src/ln/wire.rs +++ b/lightning/src/ln/wire.rs @@ -20,7 +20,7 @@ use util::ser::{Readable, Writeable, Writer}; /// decoders. pub trait CustomMessageReader { /// The type of the message decoded by the implementation. - type CustomMessage: core::fmt::Debug + Type + Writeable; + type CustomMessage: Type; /// Decodes a custom message to `CustomMessageType`. If the given message type is known to the /// implementation and the message could be decoded, must return `Ok(Some(message))`. If the /// message type is unknown to the implementation, must return `Ok(None)`. If a decoding error @@ -245,12 +245,12 @@ pub(crate) use self::encode::Encode; /// Defines a type identifier for sending messages over the wire. /// /// Messages implementing this trait specify a type and must be [`Writeable`]. -pub trait Type { +pub trait Type: core::fmt::Debug + Writeable { /// Returns the type identifying the message payload. fn type_id(&self) -> u16; } -impl Type for T where T: Encode { +impl Type for T where T: Encode { fn type_id(&self) -> u16 { T::TYPE } @@ -457,6 +457,10 @@ mod tests { } } + impl Type for () { + fn type_id(&self) -> u16 { unreachable!(); } + } + #[test] fn is_even_message_type() { let message = Message::<()>::Unknown(42);