Make the custom message traits cloneable as they're deep in nested structs
[rust-lightning] / lightning / src / ln / wire.rs
index 1191a8d3d531477977cad80776bb29f6c49ed2c8..1ceb38c7499642128480c1a8d0f4b03912842711 100644 (file)
@@ -12,9 +12,9 @@
 //!
 //! [BOLT #1]: https://github.com/lightning/bolts/blob/master/01-messaging.md
 
-use io;
-use ln::msgs;
-use util::ser::{Readable, Writeable, Writer};
+use crate::io;
+use crate::ln::msgs;
+use crate::util::ser::{Readable, Writeable, Writer};
 
 /// Trait to be implemented by custom message (unrelated to the channel/gossip LN layers)
 /// decoders.
@@ -81,7 +81,7 @@ pub(crate) enum Message<T> where T: core::fmt::Debug + Type + TestEq {
        /// A message that could not be decoded because its type is unknown.
        Unknown(u16),
        /// A message that was produced by a [`CustomMessageReader`] and is to be handled by a
-       /// [`::ln::peer_handler::CustomMessageHandler`].
+       /// [`crate::ln::peer_handler::CustomMessageHandler`].
        Custom(T),
 }
 
@@ -276,13 +276,13 @@ 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: core::fmt::Debug + Writeable {
+pub trait Type: core::fmt::Debug + Writeable + Clone {
        /// Returns the type identifying the message payload.
        fn type_id(&self) -> u16;
 }
 
 #[cfg(test)]
-pub trait Type: core::fmt::Debug + Writeable + PartialEq {
+pub trait Type: core::fmt::Debug + Writeable + Clone + PartialEq {
        fn type_id(&self) -> u16;
 }
 
@@ -292,12 +292,12 @@ impl Type for () {
 }
 
 #[cfg(test)]
-impl<T: core::fmt::Debug + Writeable + PartialEq> Type for T where T: Encode {
+impl<T: core::fmt::Debug + Writeable + Clone + PartialEq> Type for T where T: Encode {
        fn type_id(&self) -> u16 { T::TYPE }
 }
 
 #[cfg(not(test))]
-impl<T: core::fmt::Debug + Writeable> Type for T where T: Encode {
+impl<T: core::fmt::Debug + Writeable + Clone> Type for T where T: Encode {
        fn type_id(&self) -> u16 { T::TYPE }
 }
 
@@ -424,9 +424,9 @@ impl Encode for msgs::GossipTimestampFilter {
 #[cfg(test)]
 mod tests {
        use super::*;
-       use prelude::*;
+       use crate::prelude::*;
        use core::convert::TryInto;
-       use ::ln::peer_handler::IgnoringMessageHandler;
+       use crate::ln::peer_handler::IgnoringMessageHandler;
 
        // Big-endian wire encoding of Pong message (type = 19, byteslen = 2).
        const ENCODED_PONG: [u8; 6] = [0u8, 19u8, 0u8, 2u8, 0u8, 0u8];
@@ -583,7 +583,7 @@ mod tests {
                }
        }
 
-       #[derive(Eq, PartialEq, Debug)]
+       #[derive(Clone, Eq, PartialEq, Debug)]
        struct TestCustomMessage {}
 
        const CUSTOM_MESSAGE_TYPE : u16 = 9000;