pub trait MessageHandler:
Actor
+ Send
+ 'static {
// Required method
fn handle(
&mut self,
msg_any: Box<dyn Any + Send>,
actor_ref: &ActorRef<Self>,
) -> impl Future<Output = Result<Box<dyn Any + Send>>> + Send;
}Expand description
A trait for type-erased message handling within the actor system.
This trait is typically implemented automatically by the impl_message_handler! macro.
It enables the actor system to handle messages of different types by downcasting
them to their concrete types before passing them to the actor’s specific Message::handle
implementation. This trait powers the message processing capabilities of actors.
Required Methods§
Sourcefn handle(
&mut self,
msg_any: Box<dyn Any + Send>,
actor_ref: &ActorRef<Self>,
) -> impl Future<Output = Result<Box<dyn Any + Send>>> + Send
fn handle( &mut self, msg_any: Box<dyn Any + Send>, actor_ref: &ActorRef<Self>, ) -> impl Future<Output = Result<Box<dyn Any + Send>>> + Send
Handles a type-erased message.
The implementation should attempt to downcast msg_any to one of the
message types the actor supports and then call the corresponding
Message::handle method.
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.