Skip to main content

Actor

Trait Actor 

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

    // Required method
    fn handle(
        &mut self,
        message: Self::Message,
        context: &mut ActorContext,
    ) -> Result<(), ActorError>;
}
Expand description

Actor trait — the fundamental unit of computation.

Required Associated Types§

Source

type Message: Send + 'static

Message type this actor handles.

Required Methods§

Source

fn handle( &mut self, message: Self::Message, context: &mut ActorContext, ) -> Result<(), ActorError>

Handle a message.

Called for each message received by the actor. Must return quickly — don’t block or loop forever.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§