pub struct ActorRef<M: Send + 'static> { /* private fields */ }Expand description
Typed handle to an actor.
Cheap to clone (internally Arc). tell sends without waiting; ask
uses a helper pattern (ask_with) to avoid reflection.
Implementations§
Source§impl<M: Send + 'static> ActorRef<M>
impl<M: Send + 'static> ActorRef<M>
Sourcepub fn from_remote(
handle: Arc<dyn RemoteRef>,
serialize: Arc<dyn Fn(M, Option<ActorPath>) -> SerializedMessage + Send + Sync>,
) -> Self
pub fn from_remote( handle: Arc<dyn RemoteRef>, serialize: Arc<dyn Fn(M, Option<ActorPath>) -> SerializedMessage + Send + Sync>, ) -> Self
Construct a typed remote ref given a (type-erased) RemoteRef handle
and a serializer for M. Used by atomr-remote::RemoteActorRefProvider.
pub fn path(&self) -> &ActorPath
Sourcepub fn is_remote(&self) -> bool
pub fn is_remote(&self) -> bool
True if this ref points at an actor in a different ActorSystem.
Sourcepub fn tell_from(&self, msg: M, sender: Sender)
pub fn tell_from(&self, msg: M, sender: Sender)
Send msg with a typed Sender. The sender’s identity stays
type-checked end-to-end (no Any::downcast on the reply path).
Sourcepub fn is_terminated(&self) -> bool
pub fn is_terminated(&self) -> bool
Best-effort liveness check. Returns true if the user
mailbox’s receiver half has been dropped, which means the
actor cell has finished and will no longer process messages.
For Remote refs we cannot inspect the far-end mailbox, so we
always return false.
Sourcepub async fn ask_with<R, F>(
&self,
build: F,
timeout: Duration,
) -> Result<R, AskError>
pub async fn ask_with<R, F>( &self, build: F, timeout: Duration, ) -> Result<R, AskError>
Ask pattern: callers supply a closure that embeds a oneshot::Sender<R>
in the message. The future resolves when the actor replies, or errors
out on timeout/actor-stop.
Note: ask_with only works on local refs. For remote ask, use the
dedicated atomr-remote::ask_remote helper which routes the reply
through a temporary local responder actor.
Sourcepub fn as_untyped(&self) -> UntypedActorRef
pub fn as_untyped(&self) -> UntypedActorRef
Downgrade into an untyped ref for use with DeadLetters / EventStream.