pub trait Notifiable<IN>: Sized + Actor {
    fn notify<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        input: IN,
        context: &'life1 Context<Self>
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; }
Expand description

Notifiable is an extension trait for Actor that enables it to process notifications.

Note: Handler workflow guarantees that sent messages will be delivered in order.

Examples

This example assumes that messages is used with rt-tokio feature enabled.

struct Ping;

#[async_trait]
impl Actor for Ping {}

#[async_trait]
impl Notifiable<u8> for Ping {
    async fn notify(&mut self, input: u8, context: &Context<Self>) {
        println!("Received number {}", input);
    }
}

#[tokio::main]
async fn main() {
   let mut addr = Ping.spawn();
   addr.notify(42).await.unwrap();
}

Required methods

Processes notification.

Implementors