Skip to main content

Actor

Trait Actor 

Source
pub trait Actor<R: Reactor>: Send + 'static {
    // Required method
    fn on_message(
        &mut self,
        _ctx: &mut ActorContext<R>,
        _envelope: &Envelope,
        _payload: MessagePayload,
    ) -> Result<(), ActorError>;

    // Provided methods
    fn on_start(&mut self, _ctx: &mut ActorContext<R>) -> Result<(), ActorError> { ... }
    fn on_stop(&mut self, _ctx: &mut ActorContext<R>, _reason: StopReason) { ... }
}
Expand description

The core actor trait.

Implementations provide lifecycle hooks. The runtime calls on_start before the first on_message, and on_stop after the last.

Required Methods§

Source

fn on_message( &mut self, _ctx: &mut ActorContext<R>, _envelope: &Envelope, _payload: MessagePayload, ) -> Result<(), ActorError>

Provided Methods§

Source

fn on_start(&mut self, _ctx: &mut ActorContext<R>) -> Result<(), ActorError>

Source

fn on_stop(&mut self, _ctx: &mut ActorContext<R>, _reason: StopReason)

Implementors§