Skip to main content

Handler

Trait Handler 

Source
pub trait Handler<M>: Actor {
    type Response: Send + Sync;

    // Required method
    fn handle<'life0, 'async_trait>(
        &'life0 mut self,
        message: M,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Response>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Handler trait for processing messages in the swarm

A Handler can receive and process messages of a specific type. This enables actors to respond to different message types.

Required Associated Types§

Source

type Response: Send + Sync

The response type for this handler

Required Methods§

Source

fn handle<'life0, 'async_trait>( &'life0 mut self, message: M, ) -> Pin<Box<dyn Future<Output = Result<Self::Response>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handle a message and return a response

Implementors§

Source§

impl Handler<SwarmMessage> for Agent

Handler implementation for SwarmMessage - enables message processing