pub trait TellHandler<M: Send + 'static>: Send + Sync {
// Required methods
fn tell(&self, msg: M) -> BoxFuture<'_, Result<()>>;
fn tell_with_timeout(
&self,
msg: M,
timeout: Duration,
) -> BoxFuture<'_, Result<()>>;
fn blocking_tell(&self, msg: M, timeout: Option<Duration>) -> Result<()>;
fn clone_boxed(&self) -> Box<dyn TellHandler<M>>;
fn downgrade(&self) -> Box<dyn WeakTellHandler<M>>;
fn as_control(&self) -> &dyn ActorControl;
fn debug_fmt(&self, f: &mut Formatter<'_>) -> Result;
}Expand description
Fire-and-forget message handler for strong references (object-safe).
This trait allows storing different actor types that handle the same message type in a unified collection. The handlers maintain strong references to actors, keeping them alive.
§Example
ⓘ
let handlers: Vec<Box<dyn TellHandler<MyMessage>>> = vec![
(&actor_a).into(),
(&actor_b).into(),
];
for handler in &handlers {
handler.tell(MyMessage { data: 42 }).await?;
}Required Methods§
Sourcefn tell(&self, msg: M) -> BoxFuture<'_, Result<()>>
fn tell(&self, msg: M) -> BoxFuture<'_, Result<()>>
Sends a message without waiting for a reply.
Sourcefn tell_with_timeout(
&self,
msg: M,
timeout: Duration,
) -> BoxFuture<'_, Result<()>>
fn tell_with_timeout( &self, msg: M, timeout: Duration, ) -> BoxFuture<'_, Result<()>>
Sends a message with timeout.
Sourcefn blocking_tell(&self, msg: M, timeout: Option<Duration>) -> Result<()>
fn blocking_tell(&self, msg: M, timeout: Option<Duration>) -> Result<()>
Blocking version of tell.
§Timeout Behavior
timeout: None: Uses Tokio’sblocking_senddirectly. Most efficient but blocks indefinitely.timeout: Some(duration): Spawns a separate thread with a temporary runtime. Has overhead (~50-200μs for thread + ~1-10μs for runtime) but guarantees bounded waiting.
Sourcefn clone_boxed(&self) -> Box<dyn TellHandler<M>>
fn clone_boxed(&self) -> Box<dyn TellHandler<M>>
Clone this handler into a new boxed instance.
Sourcefn downgrade(&self) -> Box<dyn WeakTellHandler<M>>
fn downgrade(&self) -> Box<dyn WeakTellHandler<M>>
Downgrade to a weak handler.
Sourcefn as_control(&self) -> &dyn ActorControl
fn as_control(&self) -> &dyn ActorControl
Returns a reference to ActorControl for lifecycle management.
Use this to access identity(), is_alive(), stop(), kill(), etc.