[−][src]Struct acteur::ActorAssistant
This object is provided to the handle method in Receive and Respond traits for each message that an Actor receives.
The Actor's assistant allows to send messages and to execute some task over the system.
#[derive(Debug)] struct SalaryChanged(u32); #[derive(Debug)] struct SayByeForever(String); #[async_trait] impl Receive<SalaryChanged> for Employee { async fn handle(&mut self, message: SalaryChanged, assistant: &ActorAssistant<Employee>) { if self.salary > message.0 { assistant.send_to_actor::<Manager, SayByeForever>(self.manager_id, SayByeForever("Betrayer!".to_string())); } self.salary = message.0; } }
Implementations
impl<A: Actor> ActorAssistant<A>
[src]
pub async fn send_to_actor<'_, A2: Actor + Receive<M>, M: Debug + Send + 'static>(
&'_ self,
actor_id: A2::Id,
message: M
)
[src]
&'_ self,
actor_id: A2::Id,
message: M
)
Sends a message to the Actor with the specified Id.
If the Actor is not loaded, it will load the actor before, calling its method activate
pub async fn call_actor<'_, '_, A2: Actor + Respond<M>, M: Debug + Send + 'static>(
&'_ self,
actor_id: A2::Id,
message: M
) -> Result<<A2 as Respond<M>>::Response, &'_ str>
[src]
&'_ self,
actor_id: A2::Id,
message: M
) -> Result<<A2 as Respond<M>>::Response, &'_ str>
Sends a message to the Actor with the specified Id and waits the actor's response .
If the Actor is not loaded, it will load the actor before, calling its method activate
pub async fn send_to_service<'_, S: Service + Listen<M>, M: Debug + Send + 'static>(
&'_ self,
message: M
)
[src]
&'_ self,
message: M
)
Sends a message to a Service.
If the Service is not loaded, it will load the service before, calling its method initialize
pub async fn call_service<'_, '_, S: Service + Serve<M>, M: Debug + Send + 'static>(
&'_ self,
message: M
) -> Result<<S as Serve<M>>::Response, &'_ str>
[src]
&'_ self,
message: M
) -> Result<<S as Serve<M>>::Response, &'_ str>
Sends a message to a Service and waits for its response.
If the Service is not loaded, it will load the service before, calling its method initialize
pub async fn stop<'_>(&'_ self)
[src]
Enqueues a end command in the Actor messages queue. The actor will consume all mesages before ending. Keep in mind that event is an actor is stopped, a new message in the future can wake up the actor.
pub async fn get_id<'_, '_>(&'_ self) -> &'_ A::Id
[src]
Returns the Actor's Id defined by the Actor
Trait
pub fn stop_system(&self)
[src]
Send an stop message to all actors in the system. Actors will process all the enqued messages before stop
Trait Implementations
impl<A: Actor> Clone for ActorAssistant<A>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<A: Actor> Debug for ActorAssistant<A>
[src]
Auto Trait Implementations
impl<A> !RefUnwindSafe for ActorAssistant<A>
impl<A> Send for ActorAssistant<A> where
<A as Actor>::Id: Send,
<A as Actor>::Id: Send,
impl<A> Sync for ActorAssistant<A> where
<A as Actor>::Id: Sync,
<A as Actor>::Id: Sync,
impl<A> Unpin for ActorAssistant<A> where
<A as Actor>::Id: Unpin,
<A as Actor>::Id: Unpin,
impl<A> !UnwindSafe for ActorAssistant<A>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,