Skip to main content

TellHandler

Trait TellHandler 

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

Source

fn tell(&self, msg: M) -> BoxFuture<'_, Result<()>>

Sends a message without waiting for a reply.

Source

fn tell_with_timeout( &self, msg: M, timeout: Duration, ) -> BoxFuture<'_, Result<()>>

Sends a message with timeout.

Source

fn blocking_tell(&self, msg: M, timeout: Option<Duration>) -> Result<()>

Blocking version of tell.

timeout: None blocks indefinitely until the message is admitted; timeout: Some(duration) guarantees bounded waiting. The execution mechanism (and its overhead) depends on the calling context — see ActorRef::blocking_tell for the authoritative “Execution paths” breakdown.

§Panics

Panics only when the mailbox is full (the try_send hot path never blocks): from inside a LocalSet running on a multi-thread runtime, or from an async context that cannot block — a task on a current_thread runtime or a thread driving a current_thread runtime’s block_on (see ActorRef::blocking_tell for both conditions).

Source

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

Clone this handler into a new boxed instance.

Source

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

Downgrade to a weak handler.

Source

fn as_control(&self) -> &dyn ActorControl

Returns a reference to ActorControl for lifecycle management.

Use this to access identity(), is_alive(), stop(), kill(), 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 TellHandler<M>>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<M: Send + 'static> Debug for dyn TellHandler<M> + '_

Source§

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

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

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

Source§

fn from(actor_ref: &ActorRef<T>) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(actor_ref: ActorRef<T>) -> Self

Converts to this type from the input type.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T, M> TellHandler<M> for ActorRef<T>
where T: Actor + Message<M>, M: Send + 'static,