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§
Required Methods§
Sourcefn handle(
&mut self,
message: Self::Message,
context: &mut ActorContext,
) -> Result<(), ActorError>
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".