pub struct Context<A: Actor> { /* private fields */ }Expand description
Passed to every Actor::handle call.
Implementations§
Source§impl<A: Actor> Context<A>
impl<A: Actor> Context<A>
Sourcepub fn phase(&self) -> LifecyclePhase
pub fn phase(&self) -> LifecyclePhase
Current lifecycle phase. Phase 1.C marker — useful in
generic helpers that need to gate calls (e.g. become,
unstash_all) without taking a typed-Context<A, P>
parameter.
pub fn self_ref(&self) -> &ActorRef<A::Msg>
pub fn path(&self) -> &ActorPath
Sourcepub fn spawn<B: Actor>(
&mut self,
props: Props<B>,
name: &str,
) -> Result<ActorRef<B::Msg>, SpawnError>
pub fn spawn<B: Actor>( &mut self, props: Props<B>, name: &str, ) -> Result<ActorRef<B::Msg>, SpawnError>
Spawn a child actor under this context.
Sourcepub fn stop_child(&mut self, name: &str)
pub fn stop_child(&mut self, name: &str)
Stop a specific child.
Sourcepub fn watch<M: Send + 'static>(&mut self, target: &ActorRef<M>)
pub fn watch<M: Send + 'static>(&mut self, target: &ActorRef<M>)
Watch another actor. The sender is notified with a SystemMsg::Terminated
when the watched actor stops.
Sourcepub fn unstash_all(&mut self) -> Vec<A::Msg>
pub fn unstash_all(&mut self) -> Vec<A::Msg>
Put all stashed messages back at the front of the mailbox.
Sourcepub fn set_receive_timeout(&mut self, d: Option<Duration>)
pub fn set_receive_timeout(&mut self, d: Option<Duration>)
Set idle-receive timeout (like).
Sourcepub fn sender(&self) -> &Sender
pub fn sender(&self) -> &Sender
Typed sender of the message currently being processed.
Returns Sender::None if the sender slot was empty (the
analog of Sender == NoSender).
Sourcepub fn phased<P: PhaseMarker>(&mut self) -> Option<TypedContext<'_, A, P>>
pub fn phased<P: PhaseMarker>(&mut self) -> Option<TypedContext<'_, A, P>>
Borrow this context as a phase-typed view. The phase parameter is a
phantom witness only — call sites typically use one of
Context::starting, Context::running, or Context::stopping
to get a view whose method surface matches the phase.
Sourcepub fn starting(&mut self) -> Option<TypedContext<'_, A, Starting>>
pub fn starting(&mut self) -> Option<TypedContext<'_, A, Starting>>
Phase-typed view valid only while the actor is in Starting.
Sourcepub fn running(&mut self) -> Option<TypedContext<'_, A, Running>>
pub fn running(&mut self) -> Option<TypedContext<'_, A, Running>>
Phase-typed view valid only while the actor is in Running.
Sourcepub fn stopping_view(&mut self) -> Option<TypedContext<'_, A, Stopping>>
pub fn stopping_view(&mut self) -> Option<TypedContext<'_, A, Stopping>>
Phase-typed view valid only while the actor is in Stopping.