pub trait Handler<M>: Actor {
type Reply: 'static + Send;
// Required method
fn handle<'life0, 'life1, 'async_trait>(
&'life0 mut self,
message: M,
ctx: &'life1 ActorContext<Self>,
) -> Pin<Box<dyn Future<Output = Result<Self::Reply, ActorExitStatus>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn message_span(&self, msg_id: u64, _msg: &M) -> Span { ... }
}
Required Associated Types§
Required Methods§
Sourcefn handle<'life0, 'life1, 'async_trait>(
&'life0 mut self,
message: M,
ctx: &'life1 ActorContext<Self>,
) -> Pin<Box<dyn Future<Output = Result<Self::Reply, ActorExitStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle<'life0, 'life1, 'async_trait>(
&'life0 mut self,
message: M,
ctx: &'life1 ActorContext<Self>,
) -> Pin<Box<dyn Future<Output = Result<Self::Reply, ActorExitStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Processes a message.
If an exit status is returned as an error, the actor will exit. It will stop processing more message, the finalize method will be called, and its exit status will be the one defined in the error.
Provided Methods§
Sourcefn message_span(&self, msg_id: u64, _msg: &M) -> Span
fn message_span(&self, msg_id: u64, _msg: &M) -> Span
Returns a context span for the processing of a specific message.
msg_id
is an autoincremented message id than can be added to the span.
The counter starts 0 at the beginning of the life of an actor instance.
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.