[−][src]Struct acteur::Assistant
This object is provided to the handle method in the Receive trait 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: &Assistant<Employee>) { if self.salary > message.0 { assistant.send::<Manager, SayByeForever>(self.manager_id, SayByeForever("Betrayer!".to_string())); } self.salary = message.0; } }
Methods
impl<A: Actor> Assistant<A>
[src]
pub async fn send<'_, 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<'_, '_, 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 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 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 Assistant<A>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<A: Actor> Debug for Assistant<A>
[src]
Auto Trait Implementations
impl<A> !RefUnwindSafe for Assistant<A>
impl<A> Send for Assistant<A> where
<A as Actor>::Id: Send + Sync,
<A as Actor>::Id: Send + Sync,
impl<A> Sync for Assistant<A> where
<A as Actor>::Id: Send + Sync,
<A as Actor>::Id: Send + Sync,
impl<A> Unpin for Assistant<A> where
<A as Actor>::Id: Unpin,
<A as Actor>::Id: Unpin,
impl<A> !UnwindSafe for Assistant<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>,