Skip to main content

Actor

Trait Actor 

Source
pub trait Actor:
    Send
    + Sized
    + 'static {
    // Provided methods
    fn started(
        &mut self,
        _ctx: &Context<Self>,
    ) -> impl Future<Output = ()> + Send { ... }
    fn stopped(
        &mut self,
        _ctx: &Context<Self>,
    ) -> impl Future<Output = ()> + Send { ... }
}
Expand description

Trait for defining an actor’s lifecycle hooks.

Implement this trait (typically via #[actor]) to define started() and stopped() callbacks. Message handling is defined separately via Handler<M>.

Actors must be Send + Sized + 'static so they can be moved to a spawned task.

Provided Methods§

Source

fn started(&mut self, _ctx: &Context<Self>) -> impl Future<Output = ()> + Send

Source

fn stopped(&mut self, _ctx: &Context<Self>) -> impl Future<Output = ()> + Send

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§