pub struct Context<Msg: Message> {
pub myself: ActorRef<Msg>,
pub system: ActorSystem,
/* private fields */
}Expand description
Provides context, including the actor system during actor execution.
Context is passed to an actor’s functions, such as
receive.
Operations performed are in most cases done so from the
actor’s perspective. For example, creating a child actor
using ctx.actor_of will create the child under the current
actor within the heirarchy. In a similar manner, persistence
operations such as persist_event use the current actor’s
persistence configuration.
Since Context is specific to an actor and its functions
it is not cloneable.
Fields§
§myself: ActorRef<Msg>§system: ActorSystemImplementations§
Trait Implementations§
Source§impl<Msg: Message> ActorRefFactory for Context<Msg>
impl<Msg: Message> ActorRefFactory for Context<Msg>
fn actor_of_props<A>(
&self,
props: BoxActorProd<A>,
name: &str,
) -> Result<ActorRef<A::Msg>, CreateError>where
A: Actor,
fn actor_of<A>(
&self,
name: &str,
) -> Result<ActorRef<<A as Actor>::Msg>, CreateError>where
A: ActorFactory,
fn actor_of_args<A, Args>(
&self,
name: &str,
args: Args,
) -> Result<ActorRef<<A as Actor>::Msg>, CreateError>where
Args: ActorArgs,
A: ActorFactoryArgs<Args>,
fn stop(&self, actor: impl ActorReference)
Source§impl<Msg> ActorSelectionFactory for Context<Msg>where
Msg: Message,
impl<Msg> ActorSelectionFactory for Context<Msg>where
Msg: Message,
Source§impl<Msg> Timer for Context<Msg>where
Msg: Message,
impl<Msg> Timer for Context<Msg>where
Msg: Message,
fn schedule<T, M>( &self, initial_delay: Duration, interval: Duration, receiver: ActorRef<M>, sender: Sender, msg: T, ) -> Uuid
fn schedule_once<T, M>( &self, delay: Duration, receiver: ActorRef<M>, sender: Sender, msg: T, ) -> Uuid
fn schedule_at_time<T, M>( &self, time: DateTime<Utc>, receiver: ActorRef<M>, sender: Sender, msg: T, ) -> Uuid
fn cancel_schedule(&self, id: Uuid)
Auto Trait Implementations§
impl<Msg> Freeze for Context<Msg>
impl<Msg> !RefUnwindSafe for Context<Msg>
impl<Msg> Send for Context<Msg>
impl<Msg> Sync for Context<Msg>
impl<Msg> Unpin for Context<Msg>
impl<Msg> !UnwindSafe for Context<Msg>
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