pub struct ActorRef<A: Actor> { /* private fields */ }Expand description
External handle to a running actor. Cloneable, Send + Sync.
Use this to send messages, make requests, or wait for the actor to stop.
To stop the actor, send an explicit shutdown message through your protocol,
or call Context::stop from within a handler.
Implementations§
Source§impl<A: Actor> ActorRef<A>
impl<A: Actor> ActorRef<A>
Sourcepub fn send<M>(&self, msg: M) -> Result<(), ActorError>
pub fn send<M>(&self, msg: M) -> Result<(), ActorError>
Send a fire-and-forget message to the actor.
Sourcepub fn request_raw<M>(&self, msg: M) -> Result<Receiver<M::Result>, ActorError>
pub fn request_raw<M>(&self, msg: M) -> Result<Receiver<M::Result>, ActorError>
Send a request and get a raw oneshot receiver for the reply.
Sourcepub async fn request<M>(&self, msg: M) -> Result<M::Result, ActorError>
pub async fn request<M>(&self, msg: M) -> Result<M::Result, ActorError>
Send a request and wait for the reply (default 5s timeout).
Sourcepub async fn request_with_timeout<M>(
&self,
msg: M,
duration: Duration,
) -> Result<M::Result, ActorError>
pub async fn request_with_timeout<M>( &self, msg: M, duration: Duration, ) -> Result<M::Result, ActorError>
Send a request and wait for the reply with a custom timeout.
Trait Implementations§
Auto Trait Implementations§
impl<A> Freeze for ActorRef<A>
impl<A> !RefUnwindSafe for ActorRef<A>
impl<A> Send for ActorRef<A>
impl<A> Sync for ActorRef<A>
impl<A> Unpin for ActorRef<A>
impl<A> UnsafeUnpin for ActorRef<A>
impl<A> !UnwindSafe for ActorRef<A>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more