Actor

Trait Actor 

Source
pub trait Actor:
    Send
    + Sync
    + 'static {
    // Required method
    fn receive(&self, message: Box<dyn Any>, context: ActorCell);

    // Provided methods
    fn pre_start(&self, _context: ActorCell) { ... }
    fn post_stop(&self) { ... }
    fn pre_restart(&self, _context: ActorCell) { ... }
    fn post_restart(&self, context: ActorCell) { ... }
}
Expand description

This is the trait to implement to become an Actor.

Normaly only the receive method has to be implemented.

Required Methods§

Source

fn receive(&self, message: Box<dyn Any>, context: ActorCell)

Single method to be implemented for an Actor.

This defines the Actor’s behaviour.

Provided Methods§

Source

fn pre_start(&self, _context: ActorCell)

Method called before the Actor is started.

Source

fn post_stop(&self)

Method called after the Actor is stopped.

Source

fn pre_restart(&self, _context: ActorCell)

Method called before the Actor is restarted.

Source

fn post_restart(&self, context: ActorCell)

Method called after the Actor is restarted.

Implementors§