pub struct Instance<A: Actor> { /* private fields */ }
Expand description
An actor instance. This is responsible for managing a running actor, including its full lifecycle, supervision, signal management, etc. Instances can represent a managed actor or a “client” actor that has joined the proc.
Implementations§
Source§impl<A: Actor> Instance<A>
impl<A: Actor> Instance<A>
Sourcepub fn stop(&self) -> Result<(), ActorError>
pub fn stop(&self) -> Result<(), ActorError>
Signal the actor to stop.
Sourcepub fn open_port<M: Message>(&self) -> (PortHandle<M>, PortReceiver<M>)
pub fn open_port<M: Message>(&self) -> (PortHandle<M>, PortReceiver<M>)
Open a new port that accepts M-typed messages. The returned port may be freely cloned, serialized, and passed around. The returned receiver should only be retained by the actor responsible for processing the delivered messages.
Sourcepub fn open_once_port<M: Message>(
&self,
) -> (OncePortHandle<M>, OncePortReceiver<M>)
pub fn open_once_port<M: Message>( &self, ) -> (OncePortHandle<M>, OncePortReceiver<M>)
Open a new one-shot port that accepts M-typed messages. The returned port may be used to send a single message; ditto the receiver may receive a single message.
Sourcepub fn post(&self, port_id: PortId, headers: Attrs, message: Serialized)
pub fn post(&self, port_id: PortId, headers: Attrs, message: Serialized)
Send a message to the actor running on the proc.
Sourcepub fn self_message_with_delay<M>(
&self,
message: M,
delay: Duration,
) -> Result<(), ActorError>
pub fn self_message_with_delay<M>( &self, message: M, delay: Duration, ) -> Result<(), ActorError>
Send a message to the actor itself with a delay usually to trigger some event.
Sourcepub fn port<M: Message>(&self) -> PortHandle<M>where
A: Handler<M>,
pub fn port<M: Message>(&self) -> PortHandle<M>where
A: Handler<M>,
Return a handle port handle representing the actor’s message handler for M-typed messages.
Sourcepub fn handle(&self) -> ActorHandle<A>
pub fn handle(&self) -> ActorHandle<A>
The ActorHandle
corresponding to this instance.
Trait Implementations§
Auto Trait Implementations§
impl<A> !Freeze for Instance<A>
impl<A> !RefUnwindSafe for Instance<A>
impl<A> Send for Instance<A>
impl<A> Sync for Instance<A>
impl<A> Unpin for Instance<A>
impl<A> !UnwindSafe for Instance<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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<A, M> Handler<IndexedErasedUnbound<M>> for A
impl<A, M> Handler<IndexedErasedUnbound<M>> for A
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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