Skip to main content

Actor

Trait Actor 

Source
pub trait Actor:
    Sized
    + Send
    + 'static {
    type Msg: Send + 'static;

    // Required method
    fn handle<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        ctx: &'life1 mut Context<Self>,
        msg: Self::Msg,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn pre_start<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 mut Context<Self>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn post_stop<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 mut Context<Self>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn pre_restart<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 mut Context<Self>,
        _err: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn post_restart<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 mut Context<Self>,
        _err: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn supervisor_strategy(&self) -> SupervisorStrategy { ... }
}
Expand description

The user-facing Actor trait.

Akka.NET’s ReceiveActor is expressed here as: each actor has an associated Msg type (typically an enum) and implements an async handle that matches on it.

Required Associated Types§

Source

type Msg: Send + 'static

Required Methods§

Source

fn handle<'life0, 'life1, 'async_trait>( &'life0 mut self, ctx: &'life1 mut Context<Self>, msg: Self::Msg, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Process a single message.

Provided Methods§

Source

fn pre_start<'life0, 'life1, 'async_trait>( &'life0 mut self, _ctx: &'life1 mut Context<Self>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called once before the first message (akka.net: PreStart).

Source

fn post_stop<'life0, 'life1, 'async_trait>( &'life0 mut self, _ctx: &'life1 mut Context<Self>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called after the actor has been stopped (akka.net: PostStop).

Source

fn pre_restart<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, _ctx: &'life1 mut Context<Self>, _err: &'life2 str, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Called when the actor is about to be restarted by the supervisor.

Source

fn post_restart<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, _ctx: &'life1 mut Context<Self>, _err: &'life2 str, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Called after a restart.

Source

fn supervisor_strategy(&self) -> SupervisorStrategy

The supervisor strategy this actor applies to its own children.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§