[−][src]Struct acteur::ServiceAssistant
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.
use acteur::{Acteur, Service, Listen, ServiceConfiguration, ServiceAssistant}; #[derive(Debug)] struct EmployeeTaxesCalculator { tax_rate: f32, } #[async_trait::async_trait] impl Service for EmployeeTaxesCalculator { async fn initialize(system: &ServiceAssistant<Self>) -> (Self, ServiceConfiguration) { let service = EmployeeTaxesCalculator { tax_rate: 0.21, }; let service_conf = ServiceConfiguration::default(); (service, service_conf) } } #[derive(Debug)] struct EmployeeSalaryChange(u32); #[async_trait::async_trait] impl Listen<EmployeeSalaryChange> for EmployeeTaxesCalculator { async fn handle(&self, message: EmployeeSalaryChange, system: &ServiceAssistant<Self>) { system.stop_system(); } }
Implementations
impl<S: Service> ServiceAssistant<S>
[src]
pub async fn send_to_actor<A: Actor + Receive<M>, M: Debug + Send + 'static, '_>(
&'_ self,
actor_id: A::Id,
message: M
)
[src]
&'_ self,
actor_id: A::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 send_to_all_actors<A: Actor + Receive<M>, M: Debug + Send + 'static, '_>(
&'_ self,
message: M
)
[src]
&'_ self,
message: M
)
Sends a message to all actors of a type, independently of the ID. It will only send messages to actors already in Ram (already loaded)
pub async fn schedule_send_to_actor<A: Actor + Receive<M>, M: Debug + Send + 'static, '_>(
&'_ self,
actor_id: A::Id,
duration: Duration,
message: M
)
[src]
&'_ self,
actor_id: A::Id,
duration: Duration,
message: M
)
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<A: Actor + Receive<M>, M: Debug + Send + 'static, '_>(
&'_ self,
duration: Duration,
message: M
)
[src]
&'_ self,
duration: Duration,
message: M
)
Schedules to sends a message to all actor of a type, independently of the ID. It will only send messages to actors already in Ram (already loaded)
pub async fn call_actor<A: Actor + Respond<M>, M: Debug + Send + 'static, '_, '_>(
&'_ self,
actor_id: A::Id,
message: M
) -> Result<<A as Respond<M>>::Response, &'_ str>
[src]
&'_ self,
actor_id: A::Id,
message: M
) -> Result<<A 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<S1: 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<S1: Service + Serve<M>, M: Debug + Send + 'static, '_, '_>(
&'_ self,
message: M
) -> Result<<S1 as Serve<M>>::Response, &'_ str>
[src]
&'_ self,
message: M
) -> Result<<S1 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 fn stop_system(&self)
[src]
Send an stop message to all actors in the system. Actors will process all the enqued messages before stop
pub async fn subscribe<M: Sync + Send + Debug + 'static, '_>(&'_ self) where
S: Service + Listen<M>,
[src]
S: Service + Listen<M>,
Trait Implementations
impl<S: Service> Clone for ServiceAssistant<S>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<S: Service> Debug for ServiceAssistant<S>
[src]
Auto Trait Implementations
impl<S> !RefUnwindSafe for ServiceAssistant<S>
impl<S> Send for ServiceAssistant<S>
impl<S> Sync for ServiceAssistant<S>
impl<S> Unpin for ServiceAssistant<S> where
S: Unpin,
S: Unpin,
impl<S> !UnwindSafe for ServiceAssistant<S>
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>,