[][src]Struct acteur::Assistant

pub struct Assistant<A: Actor> { /* fields omitted */ }

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]

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]

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]

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

impl<A> Sync for Assistant<A> where
    <A as Actor>::Id: Send + Sync

impl<A> Unpin for Assistant<A> where
    <A as Actor>::Id: Unpin

impl<A> !UnwindSafe for Assistant<A>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,