pub struct ActorRef<A: Actor> { /* private fields */ }
Expand description
A handle to an actor, that allows messages to be sent to the actor.
As long as one ActorRef exists, the actor will continue to run.
Implementations§
Source§impl<A: Actor> ActorRef<A>
impl<A: Actor> ActorRef<A>
Sourcepub async fn send(&self, msg: A::Message) -> Result<(), A::Message>
pub async fn send(&self, msg: A::Message) -> Result<(), A::Message>
Sends a message to the actor. If the mailbox is full, the message will be returned in Err
.
Sourcepub fn stop(&self, stop: A::Message) -> Result<(), A::Message>
pub fn stop(&self, stop: A::Message) -> Result<(), A::Message>
Stops the actor by sending a stop message to it. If a stop message has already been sent,
the stop message will be returned in Err
.
Sourcepub fn downgrade(&self) -> WeakActorRef<A>
pub fn downgrade(&self) -> WeakActorRef<A>
Creates a WeakActorRef
from this ActorRef
, which can be used as a handle to the actor that
doesn’t keep the actor alive, if it is the last handle to the actor.
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> !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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more