Skip to main content

WeakTellHandler

Trait WeakTellHandler 

Source
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§

Source

fn upgrade(&self) -> Option<Box<dyn TellHandler<M>>>

Attempts to upgrade to a strong handler. Returns None if the actor has been dropped.

Source

fn clone_boxed(&self) -> Box<dyn WeakTellHandler<M>>

Clone this handler into a new boxed instance.

Source

fn as_weak_control(&self) -> &dyn WeakActorControl

Returns a reference to WeakActorControl for lifecycle management.

Use this to access identity(), is_alive(), upgrade(), etc.

Source

fn debug_fmt(&self, f: &mut Formatter<'_>) -> Result

Debug formatting support for trait objects.

Trait Implementations§

Source§

impl<M: Send + 'static> Clone for Box<dyn WeakTellHandler<M>>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<M: Send + 'static> Debug for Box<dyn WeakTellHandler<M>>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, M> From<&ActorWeak<T>> for Box<dyn WeakTellHandler<M>>
where T: Actor + Message<M> + 'static, M: Send + 'static,

Source§

fn from(actor_weak: &ActorWeak<T>) -> Self

Converts to this type from the input type.
Source§

impl<T, M> From<ActorWeak<T>> for Box<dyn WeakTellHandler<M>>
where T: Actor + Message<M> + 'static, M: Send + 'static,

Source§

fn from(actor_weak: ActorWeak<T>) -> Self

Converts to this type from the input type.

Implementors§

Source§

impl<T, M> WeakTellHandler<M> for ActorWeak<T>
where T: Actor + Message<M> + 'static, M: Send + 'static,