Struct tiny_tokio_actor::ActorContext
source · pub struct ActorContext<E: SystemEvent> {
pub path: ActorPath,
pub system: ActorSystem<E>,
}Expand description
The actor context gives a running actor access to its path, as well as the system that is running it.
Fields§
§path: ActorPath§system: ActorSystem<E>Implementations§
source§impl<E: SystemEvent> ActorContext<E>
impl<E: SystemEvent> ActorContext<E>
sourcepub async fn create_child<A: Actor<E>>(
&self,
name: &str,
actor: A
) -> Result<ActorRef<E, A>, ActorError>
pub async fn create_child<A: Actor<E>>(
&self,
name: &str,
actor: A
) -> Result<ActorRef<E, A>, ActorError>
Create a child actor under this actor.
sourcepub async fn get_child<A: Actor<E>>(&self, name: &str) -> Option<ActorRef<E, A>>
pub async fn get_child<A: Actor<E>>(&self, name: &str) -> Option<ActorRef<E, A>>
Retrieve a child actor running under this actor.
sourcepub async fn get_or_create_child<A, F>(
&self,
name: &str,
actor_fn: F
) -> Result<ActorRef<E, A>, ActorError>where
A: Actor<E>,
F: FnOnce() -> A,
pub async fn get_or_create_child<A, F>(
&self,
name: &str,
actor_fn: F
) -> Result<ActorRef<E, A>, ActorError>where
A: Actor<E>,
F: FnOnce() -> A,
Retrieve or create a new child under this actor if it does not exist yet
sourcepub async fn stop_child(&self, name: &str)
pub async fn stop_child(&self, name: &str)
Stops the child actor