Struct rings_node::prelude::message::MessageHandler
source · pub struct MessageHandler { /* private fields */ }Expand description
MessageHandler will manage resources.
Implementations§
source§impl MessageHandler
impl MessageHandler
sourcepub fn new(
swarm: Arc<Swarm>,
callback: Option<Box<dyn MessageCallback + Sync + Send + 'static, Global>>,
validator: Option<Box<dyn MessageValidator + Sync + Send + 'static, Global>>
) -> MessageHandler
pub fn new(
swarm: Arc<Swarm>,
callback: Option<Box<dyn MessageCallback + Sync + Send + 'static, Global>>,
validator: Option<Box<dyn MessageValidator + Sync + Send + 'static, Global>>
) -> MessageHandler
Create a new MessageHandler Instance.
sourcepub fn decrypt_msg(
&self,
msg: &MaybeEncrypted<CustomMessage>
) -> Result<CustomMessage, Error>
pub fn decrypt_msg(
&self,
msg: &MaybeEncrypted<CustomMessage>
) -> Result<CustomMessage, Error>
Decrypt message.
sourcepub fn handle_payload<'life0, 'life_self, 'async_recursion>(
&'life_self self,
payload: &'life0 MessagePayload<Message>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_recursion, Global>>where
'life0: 'async_recursion,
'life_self: 'async_recursion,
pub fn handle_payload<'life0, 'life_self, 'async_recursion>(
&'life_self self,
payload: &'life0 MessagePayload<Message>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_recursion, Global>>where
'life0: 'async_recursion,
'life_self: 'async_recursion,
Handle builtin message.
sourcepub async fn listen_once(
&self
) -> impl Future<Output = Option<MessagePayload<Message>>>
pub async fn listen_once(
&self
) -> impl Future<Output = Option<MessagePayload<Message>>>
This method is required because web-sys components is not Send
which means a listening loop cannot running concurrency.
Trait Implementations§
source§impl Clone for MessageHandler
impl Clone for MessageHandler
source§fn clone(&self) -> MessageHandler
fn clone(&self) -> MessageHandler
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl HandleMsg<AlreadyConnected> for MessageHandler
impl HandleMsg<AlreadyConnected> for MessageHandler
source§fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
_msg: &'life2 AlreadyConnected
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
_msg: &'life2 AlreadyConnected
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
Message handler.
source§impl HandleMsg<ConnectNodeReport> for MessageHandler
impl HandleMsg<ConnectNodeReport> for MessageHandler
source§fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 ConnectNodeReport
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 ConnectNodeReport
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
Message handler.
source§impl HandleMsg<ConnectNodeSend> for MessageHandler
impl HandleMsg<ConnectNodeSend> for MessageHandler
source§fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 ConnectNodeSend
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 ConnectNodeSend
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
Message handler.
source§impl HandleMsg<FindSuccessorReport> for MessageHandler
impl HandleMsg<FindSuccessorReport> for MessageHandler
source§fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 FindSuccessorReport
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 FindSuccessorReport
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
Message handler.
source§impl HandleMsg<FindSuccessorSend> for MessageHandler
impl HandleMsg<FindSuccessorSend> for MessageHandler
source§fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 FindSuccessorSend
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 FindSuccessorSend
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
Message handler.
source§impl HandleMsg<FoundVNode> for MessageHandler
impl HandleMsg<FoundVNode> for MessageHandler
source§fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 FoundVNode
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 FoundVNode
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
Message handler.
source§impl HandleMsg<JoinDHT> for MessageHandler
impl HandleMsg<JoinDHT> for MessageHandler
source§fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 JoinDHT
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 JoinDHT
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
Message handler.
source§impl HandleMsg<LeaveDHT> for MessageHandler
impl HandleMsg<LeaveDHT> for MessageHandler
source§fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 MessagePayload<Message>,
msg: &'life2 LeaveDHT
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 MessagePayload<Message>,
msg: &'life2 LeaveDHT
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
Message handler.
source§impl HandleMsg<MaybeEncrypted<CustomMessage>> for MessageHandler
impl HandleMsg<MaybeEncrypted<CustomMessage>> for MessageHandler
source§fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
__arg2: &'life2 MaybeEncrypted<CustomMessage>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
__arg2: &'life2 MaybeEncrypted<CustomMessage>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
Message handler.
source§impl HandleMsg<NotifyPredecessorReport> for MessageHandler
impl HandleMsg<NotifyPredecessorReport> for MessageHandler
source§fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 MessagePayload<Message>,
msg: &'life2 NotifyPredecessorReport
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 MessagePayload<Message>,
msg: &'life2 NotifyPredecessorReport
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
Message handler.
source§impl HandleMsg<NotifyPredecessorSend> for MessageHandler
impl HandleMsg<NotifyPredecessorSend> for MessageHandler
source§fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 NotifyPredecessorSend
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 NotifyPredecessorSend
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
Message handler.
source§impl HandleMsg<SearchVNode> for MessageHandler
impl HandleMsg<SearchVNode> for MessageHandler
source§fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 SearchVNode
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 SearchVNode
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
Search VNode via successor If a VNode is storead local, it will response immediately.
source§impl HandleMsg<SyncVNodeWithSuccessor> for MessageHandler
impl HandleMsg<SyncVNodeWithSuccessor> for MessageHandler
source§fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 MessagePayload<Message>,
msg: &'life2 SyncVNodeWithSuccessor
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 MessagePayload<Message>,
msg: &'life2 SyncVNodeWithSuccessor
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
Message handler.
source§impl HandleMsg<VNodeOperation> for MessageHandler
impl HandleMsg<VNodeOperation> for MessageHandler
source§fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 VNodeOperation
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 MessagePayload<Message>,
msg: &'life2 VNodeOperation
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MessageHandler: 'async_trait,
Message handler.