Skip to main content

ActorRef

Struct ActorRef 

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

Source

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.

Source

pub fn path(&self) -> &ActorPath

Source

pub fn is_remote(&self) -> bool

True if this ref points at an actor in a different ActorSystem.

Source

pub fn tell(&self, msg: M)

Fire-and-forget send.

Source

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).

Source

pub fn stop(&self)

Stop the actor.

Source

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.

Source

pub async fn ask_with<R, F>( &self, build: F, timeout: Duration, ) -> Result<R, AskError>
where R: Send + 'static, F: FnOnce(Sender<R>) -> M,

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.

Source

pub fn as_untyped(&self) -> UntypedActorRef

Downgrade into an untyped ref for use with DeadLetters / EventStream.

Trait Implementations§

Source§

impl<M: Send + 'static> Clone for ActorRef<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 ActorRef<M>

Source§

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

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

impl<M: Send + 'static> From<&ActorRef<M>> for Sender

Source§

fn from(r: &ActorRef<M>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<M> Freeze for ActorRef<M>

§

impl<M> !RefUnwindSafe for ActorRef<M>

§

impl<M> Send for ActorRef<M>

§

impl<M> Sync for ActorRef<M>

§

impl<M> Unpin for ActorRef<M>

§

impl<M> UnsafeUnpin for ActorRef<M>

§

impl<M> !UnwindSafe for ActorRef<M>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Extension for T
where T: Any + Send + Sync,