crb_actor/interrupt.rs
1use crate::actor::Actor;
2use crate::message::MessageFor;
3use crate::runtime::Address;
4use anyhow::Result;
5use async_trait::async_trait;
6
7impl<A: Actor> Address<A> {
8 pub fn interrupt(&self) -> Result<()> {
9 self.send(Interrupt)
10 }
11}
12
13struct Interrupt;
14
15#[async_trait]
16impl<A: Actor> MessageFor<A> for Interrupt {
17 async fn handle(self: Box<Self>, actor: &mut A, ctx: &mut A::Context) -> Result<()> {
18 actor.interrupt(ctx).await
19 }
20}