/// 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;
}
}
#[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 }
}
}
}
- #[derive(Eq, PartialEq, Debug)]
+ #[derive(Clone, Eq, PartialEq, Debug)]
struct TestCustomMessage {}
const CUSTOM_MESSAGE_TYPE : u16 = 9000;
fn invalid_custom_message_type() {
let nodes = create_nodes(2);
+ #[derive(Clone)]
struct InvalidCustomMessage{}
impl CustomOnionMessageContents for InvalidCustomMessage {
fn tlv_type(&self) -> u64 {
/// // ChannelManager.
/// let onion_messenger = OnionMessenger::new(&keys_manager, logger, your_custom_message_handler);
///
+/// # #[derive(Clone)]
/// # struct YourCustomMessage {}
/// impl Writeable for YourCustomMessage {
/// fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
}
}
-#[derive(Debug)]
+#[derive(Clone, Debug)]
/// The contents of an onion message. In the context of offers, this would be the invoice, invoice
/// request, or invoice error.
pub enum OnionMessageContents<T: CustomOnionMessageContents> {
}
/// The contents of a custom onion message.
-pub trait CustomOnionMessageContents: Writeable {
+pub trait CustomOnionMessageContents: Writeable + Clone {
/// Returns the TLV type identifying the message contents. MUST be >= 64.
fn tlv_type(&self) -> u64;
}