pub trait CustomOnionMessageHandler {
type CustomMessage: CustomOnionMessageContents;
// Required methods
fn handle_custom_message(&self, msg: Self::CustomMessage);
fn read_custom_message<R: Read>(
&self,
message_type: u64,
buffer: &mut R
) -> Result<Option<Self::CustomMessage>, DecodeError>;
}
Expand description
Handler for custom onion messages. If you are using SimpleArcOnionMessenger
,
SimpleRefOnionMessenger
, or prefer to ignore inbound custom onion messages,
IgnoringMessageHandler
must be provided to OnionMessenger::new
. Otherwise, a custom
implementation of this trait must be provided, with CustomMessage
specifying the supported
message types.
See OnionMessenger
for example usage.
Required Associated Types§
sourcetype CustomMessage: CustomOnionMessageContents
type CustomMessage: CustomOnionMessageContents
The message known to the handler. To support multiple message types, you may want to make this an enum with a variant for each supported message.
Required Methods§
sourcefn handle_custom_message(&self, msg: Self::CustomMessage)
fn handle_custom_message(&self, msg: Self::CustomMessage)
Called with the custom message that was received.
sourcefn read_custom_message<R: Read>(
&self,
message_type: u64,
buffer: &mut R
) -> Result<Option<Self::CustomMessage>, DecodeError>
fn read_custom_message<R: Read>( &self, message_type: u64, buffer: &mut R ) -> Result<Option<Self::CustomMessage>, DecodeError>
Read a custom message of type message_type
from buffer
, returning Ok(None)
if the
message type is unknown.