Actor

Trait Actor 

Source
pub trait Actor:
    Send
    + Sync
    + 'static {
    type Error;

    // Provided methods
    fn initialize(
        &mut self,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send { ... }
    fn deinitialize(&self) -> impl Future<Output = ()> + Send { ... }
}
Expand description

§Actor

This trait defines the interface between the system and the actor. The methods defined in this trait provide the actor’s only chances to access itself mutably in an async context. All actors must implement this trait.

Required Associated Types§

Source

type Error

§[Error]

This associated type contains the error type that can be returned by methods defined by this trait.

Provided Methods§

Source

fn initialize(&mut self) -> impl Future<Output = Result<(), Self::Error>> + Send

§[initialize]

Called immediately before the actor is added to the system.

Source

fn deinitialize(&self) -> impl Future<Output = ()> + Send

§[deinitialize]

Called immediately after the actor is shut down. This will be the last opportunity the actor has to execute any code in an async context.

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§