[−][src]Trait act_zero::Actor
Implement this trait for types representing actors. The only requirement
is that you specify an Error
type, all other methods are optional.
Associated Types
Loading content...Provided methods
fn started(&mut self, _addr: Addr<Local<Self>>) -> Result<(), Self::Error> where
Self: Sized,
Self: Sized,
Called automatically after an actor is spawned but before any messages are processed. Use
this if you want the actor to keep a reference to itself. Usually you would first downcast
the Addr
to a WeakAddr
to avoid the actor keeping itself alive.
fn errored_fut(_error: Self::Error) -> bool
Called when a future running on this actor returns an error. Use this method to log the
error. Return true
to stop the actor immediately.
The default implementation discards the error and returns false
.
fn errored(&self, error: Self::Error) -> bool
Called when a method taking &self
returns an error. Use this method to log the
error. Return true
to stop the actor immediately.
The default implementation defers to Self::errored_fut
.
fn errored_mut(&mut self, error: Self::Error) -> bool
Called when a method taking &mut self
returns an error. Use this method to log the
error. Return true
to stop the actor immediately.
The default implementation first calls Self::errored
, and then returns true
.
fn should_terminate(&self) -> bool
Called after every actor method. If this returns true
the actor will stop immediately.
This can be used to gracefully shutdown the actor without returning an error.
The default implementation returns false
, so the actor will only stop when there are
no more strong references to it.