pub trait WeakTellHandler<M: Send + 'static>: Send + Sync {
// Required methods
fn upgrade(&self) -> Option<Box<dyn TellHandler<M>>>;
fn clone_boxed(&self) -> Box<dyn WeakTellHandler<M>>;
fn as_weak_control(&self) -> &dyn WeakActorControl;
fn debug_fmt(&self, f: &mut Formatter<'_>) -> Result;
}Expand description
Weak handler for fire-and-forget messages (object-safe).
Unlike TellHandler, this does not keep the actor alive.
Must call upgrade() to obtain a strong handler before sending messages.
§Example
ⓘ
let weak_handlers: Vec<Box<dyn WeakTellHandler<MyMessage>>> = vec![
ActorRef::downgrade(&actor_a).into(),
ActorRef::downgrade(&actor_b).into(),
];
for handler in &weak_handlers {
if let Some(strong) = handler.upgrade() {
strong.tell(MyMessage { data: 42 }).await?;
}
}Required Methods§
Sourcefn upgrade(&self) -> Option<Box<dyn TellHandler<M>>>
fn upgrade(&self) -> Option<Box<dyn TellHandler<M>>>
Attempts to upgrade to a strong handler.
Returns None if the actor has been dropped.
Sourcefn clone_boxed(&self) -> Box<dyn WeakTellHandler<M>>
fn clone_boxed(&self) -> Box<dyn WeakTellHandler<M>>
Clone this handler into a new boxed instance.
Sourcefn as_weak_control(&self) -> &dyn WeakActorControl
fn as_weak_control(&self) -> &dyn WeakActorControl
Returns a reference to WeakActorControl for lifecycle management.
Use this to access identity(), is_alive(), upgrade(), etc.