Skip to main content

Actor

Trait Actor 

Source
pub trait Actor:
    Send
    + Sized
    + 'static {
    // Provided methods
    fn started(&mut self, _ctx: &Context<Self>) { ... }
    fn stopped(&mut self, _ctx: &Context<Self>) { ... }
}
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 thread.

Provided Methods§

Source

fn started(&mut self, _ctx: &Context<Self>)

Source

fn stopped(&mut self, _ctx: &Context<Self>)

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§