pub trait MessageHandler: Send + 'static {
// Required method
fn handle(
&mut self,
msg_any: Box<dyn Any + Send>,
actor_ref: &ActorRef,
) -> impl Future<Output = Result<Box<dyn Any + Send>>> + Send;
}Expand description
A trait for type-erased message handling within the actor’s Runtime.
This trait is typically implemented automatically by the impl_message_handler! macro.
It allows the Runtime to handle messages of different types by downcasting
them to their concrete types before passing them to the actor’s specific Message::handle
implementation.
Required Methods§
Sourcefn handle(
&mut self,
msg_any: Box<dyn Any + Send>,
actor_ref: &ActorRef,
) -> impl Future<Output = Result<Box<dyn Any + Send>>> + Send
fn handle( &mut self, msg_any: Box<dyn Any + Send>, actor_ref: &ActorRef, ) -> 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.