pub struct Context<'a, A: Actor> { /* private fields */ }
Expand description
Context for a message currently being handled by an Instance.
Implementations§
Methods from Deref<Target = 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, A> Freeze for Context<'a, A>
impl<'a, A> !RefUnwindSafe for Context<'a, A>
impl<'a, A> Send for Context<'a, A>
impl<'a, A> Sync for Context<'a, A>
impl<'a, A> Unpin for Context<'a, A>
impl<'a, A> !UnwindSafe for Context<'a, 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
§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>
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