pub trait CustomOnionMessageHandler {
type CustomMessage: CustomOnionMessageContents;
// Required methods
fn handle_custom_message(
&self,
msg: Self::CustomMessage,
) -> Option<Self::CustomMessage>;
fn read_custom_message<R>(
&self,
message_type: u64,
buffer: &mut R,
) -> Result<Option<Self::CustomMessage>, DecodeError>
where R: Read;
}
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§
type 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§
fn handle_custom_message(
&self,
msg: Self::CustomMessage,
) -> Option<Self::CustomMessage>
fn handle_custom_message( &self, msg: Self::CustomMessage, ) -> Option<Self::CustomMessage>
Called with the custom message that was received, returning a response to send, if any.
fn read_custom_message<R>(
&self,
message_type: u64,
buffer: &mut R,
) -> Result<Option<Self::CustomMessage>, DecodeError>where
R: Read,
fn read_custom_message<R>(
&self,
message_type: u64,
buffer: &mut R,
) -> Result<Option<Self::CustomMessage>, DecodeError>where
R: Read,
Read a custom message of type message_type
from buffer
, returning Ok(None)
if the
message type is unknown.
Object Safety§
This trait is not object safe.