Trait robots::actors::actor_cell::ActorContext
[−]
[src]
pub trait ActorContext { fn actor_ref(&self) -> ActorRef; fn actor_of(
&self,
props: Arc<ActorFactory>,
name: String
) -> Result<ActorRef, &'static str>; fn tell<MessageTo: Message>(&self, to: ActorRef, message: MessageTo); fn ask<MessageTo: Message>(
&self,
to: ActorRef,
message: MessageTo,
future_name: String
) -> ActorRef; fn complete<MessageTo: Message>(&self, to: ActorRef, complete: MessageTo); fn forward_result<T: Message>(&self, future: ActorRef, to: ActorRef); fn forward_result_to_future<T: Message>(
&self,
future: ActorRef,
to: ActorRef
); fn do_computation<T: Message, F: Fn(Box<Any + Send>, ActorCell) -> T + Send + Sync + 'static>(
&self,
future: ActorRef,
closure: F
); fn stop(&self, actor_ref: ActorRef); fn kill_me(&self); fn sender(&self) -> ActorRef; fn father(&self) -> ActorRef; fn children(&self) -> HashMap<Arc<ActorPath>, ActorRef>; fn monitoring(&self) -> HashMap<Arc<ActorPath>, (ActorRef, FailureHandler)>; fn monitored_by(&self) -> Vec<ActorRef>; fn monitor(&self, actor: ActorRef, handler: FailureHandler); fn path(&self) -> Arc<ActorPath>; fn identify_actor(
&self,
logical_path: String,
request_name: String
) -> ActorRef; fn tell_control(&self, actor: ActorRef, message: ControlMessage); fn fail(&self, reason: &'static str); }
This is the API that Actors are supposed to see of their context while handling a message.
Required Methods
fn actor_ref(&self) -> ActorRef
Returns an ActorRef to the Actor.
fn actor_of(
&self,
props: Arc<ActorFactory>,
name: String
) -> Result<ActorRef, &'static str>
&self,
props: Arc<ActorFactory>,
name: String
) -> Result<ActorRef, &'static str>
Spawns a child actor.
fn tell<MessageTo: Message>(&self, to: ActorRef, message: MessageTo)
Sends a Message to the targeted ActorRef.
fn ask<MessageTo: Message>(
&self,
to: ActorRef,
message: MessageTo,
future_name: String
) -> ActorRef
&self,
to: ActorRef,
message: MessageTo,
future_name: String
) -> ActorRef
Creates a Future, this Future will send the message to the targetted ActorRef (and thus be the sender of the message).
fn complete<MessageTo: Message>(&self, to: ActorRef, complete: MessageTo)
Completes a Future.
fn forward_result<T: Message>(&self, future: ActorRef, to: ActorRef)
Tells a future to forward its result to another Actor. The Future is then dropped.
fn forward_result_to_future<T: Message>(&self, future: ActorRef, to: ActorRef)
Tells a future to forward its result to another Future that will be completed with this result. The Future is then dropped.
fn do_computation<T: Message, F: Fn(Box<Any + Send>, ActorCell) -> T + Send + Sync + 'static>(
&self,
future: ActorRef,
closure: F
)
&self,
future: ActorRef,
closure: F
)
Sends the Future a closure to apply on its value, the value will be updated with the output of the closure.
fn stop(&self, actor_ref: ActorRef)
Requests the targeted actor to stop.
fn kill_me(&self)
Asks the father of the actor to terminate it.
fn sender(&self) -> ActorRef
Returns an Arc to the sender of the message being handled.
fn father(&self) -> ActorRef
Father of the actor.
fn children(&self) -> HashMap<Arc<ActorPath>, ActorRef>
Children of the actor.
fn monitoring(&self) -> HashMap<Arc<ActorPath>, (ActorRef, FailureHandler)>
Lifecycle monitoring, list of monitored actors.
fn monitored_by(&self) -> Vec<ActorRef>
Actors monitoring this actor.
fn monitor(&self, actor: ActorRef, handler: FailureHandler)
Monitor an actor with the given handler.
fn path(&self) -> Arc<ActorPath>
Logical path to the actor, such as /user/foo/bar/baz
fn identify_actor(&self, logical_path: String, request_name: String) -> ActorRef
Future containing an Option
The future will have the path: $actor/$name_request
fn tell_control(&self, actor: ActorRef, message: ControlMessage)
Sends a control message to the given actor.
fn fail(&self, reason: &'static str)
Puts the actor in a state of failure with the given reason.
Implementors
impl ActorContext for ActorCell