[][src]Struct acteur::ActorAssistant

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

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]

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 send_to_all_actors<A2: Actor + Receive<M>, M: Debug + Send + 'static, '_>(
    &'_ self,
    message: M
)
[src]

Sends a message to all actors independently of the ID. It will only send messages to actors already in Ram (already loaded)

pub async fn schedule_send_to_actor<A2: Actor + Receive<M>, M: Debug + Send + 'static, '_>(
    &'_ self,
    actor_id: A2::Id,
    duration: Duration,
    message: M
)
[src]

Schedules to 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 schedule_send_to_all_actors<A2: Actor + Receive<M>, M: Debug + Send + 'static, '_>(
    &'_ self,
    duration: Duration,
    message: M
)
[src]

Schedules to sends a message to all actors independently of the ID. It will only send messages to actors already in Ram (already loaded)

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]

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]

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]

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]

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

impl<A> Sync for ActorAssistant<A> where
    <A as Actor>::Id: Sync

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

impl<A> !UnwindSafe for ActorAssistant<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>,