/// 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
/// 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
ReplyChannelRange(msgs::ReplyChannelRange),
GossipTimestampFilter(msgs::GossipTimestampFilter),
/// A message that could not be decoded because its type is unknown.
ReplyChannelRange(msgs::ReplyChannelRange),
GossipTimestampFilter(msgs::GossipTimestampFilter),
/// A message that could not be decoded because its type is unknown.
/// A message that was produced by a [`CustomMessageReader`] and is to be handled by a
/// [`::ln::peer_handler::CustomMessageHandler`].
Custom(T),
}
/// A message that was produced by a [`CustomMessageReader`] and is to be handled by a
/// [`::ln::peer_handler::CustomMessageHandler`].
Custom(T),
}
match self {
&Message::Init(ref msg) => msg.type_id(),
&Message::Error(ref msg) => msg.type_id(),
match self {
&Message::Init(ref msg) => msg.type_id(),
&Message::Error(ref msg) => msg.type_id(),
- (self.0 & 1) == 0
- }
-}
-
-impl ::core::fmt::Display for MessageType {
- fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
- write!(f, "{}", self.0)
+ (self.type_id() & 1) == 0
if let Some(custom) = custom_reader.read(message_type, buffer)? {
Ok(Message::Custom(custom))
} else {
if let Some(custom) = custom_reader.read(message_type, buffer)? {
Ok(Message::Custom(custom))
} else {
///
/// Returns an I/O error if the write could not be completed.
pub(crate) fn write<M: Type + Writeable, W: Writer>(message: &M, buffer: &mut W) -> Result<(), io::Error> {
///
/// Returns an I/O error if the write could not be completed.
pub(crate) fn write<M: Type + Writeable, W: Writer>(message: &M, buffer: &mut W) -> Result<(), io::Error> {
/// Defines a type identifier for sending messages over the wire.
///
/// Messages implementing this trait specify a type and must be [`Writeable`].
/// Defines a type identifier for sending messages over the wire.
///
/// Messages implementing this trait specify a type and must be [`Writeable`].
let mut reader = io::Cursor::new(buffer);
let message = read(&mut reader, &IgnoringMessageHandler{}).unwrap();
match message {
let mut reader = io::Cursor::new(buffer);
let message = read(&mut reader, &IgnoringMessageHandler{}).unwrap();
match message {
_ => panic!("Expected message type {}; found: {}", ::core::u16::MAX, message.type_id()),
}
}
_ => panic!("Expected message type {}; found: {}", ::core::u16::MAX, message.type_id()),
}
}
let decoded_msg = read(&mut reader, &TestCustomMessageReader{}).unwrap();
match decoded_msg {
Message::Custom(custom) => {
let decoded_msg = read(&mut reader, &TestCustomMessageReader{}).unwrap();
match decoded_msg {
Message::Custom(custom) => {
assert_eq!(custom, TestCustomMessage {});
},
_ => panic!("Expected custom message, found message type: {}", decoded_msg.type_id()),
assert_eq!(custom, TestCustomMessage {});
},
_ => panic!("Expected custom message, found message type: {}", decoded_msg.type_id()),