pub trait WeakActorControl: Send + Sync {
// Required methods
fn identity(&self) -> Identity;
fn is_alive(&self) -> bool;
fn upgrade(&self) -> Option<Box<dyn ActorControl>>;
fn clone_boxed(&self) -> Box<dyn WeakActorControl>;
fn debug_fmt(&self, f: &mut Formatter<'_>) -> Result;
}Expand description
Type-erased trait for actor lifecycle control with weak references.
Unlike ActorControl, this does not keep the actor alive.
Must call upgrade() to obtain a strong control before
performing lifecycle operations.
§Example
ⓘ
let weak_controls: Vec<Box<dyn WeakActorControl>> = vec![
ActorRef::downgrade(&actor_a).into(),
ActorRef::downgrade(&actor_b).into(),
];
for control in &weak_controls {
if let Some(strong) = control.upgrade() {
strong.stop().await?;
}
}Required Methods§
Sourcefn is_alive(&self) -> bool
fn is_alive(&self) -> bool
Checks if the actor might still be alive (heuristic, not guaranteed).
Sourcefn upgrade(&self) -> Option<Box<dyn ActorControl>>
fn upgrade(&self) -> Option<Box<dyn ActorControl>>
Attempts to upgrade to a strong control reference.
Returns None if the actor has been dropped.
Sourcefn clone_boxed(&self) -> Box<dyn WeakActorControl>
fn clone_boxed(&self) -> Box<dyn WeakActorControl>
Clone this control into a new boxed instance.