pub struct System { /* private fields */ }Expand description
Systems are responsible for keeping track of their spawned actors, and managing their lifecycles appropriately.
You may run multiple systems in the same application, each system being responsible for its own pool of actors.
Implementations§
Source§impl System
impl System
pub fn with_callbacks(name: &str, callbacks: SystemCallbacks) -> Self
Sourcepub fn prepare<A>(
&mut self,
actor: A,
) -> SpawnBuilderWithoutAddress<'_, A, impl FnOnce() -> A>where
A: Actor,
pub fn prepare<A>(
&mut self,
actor: A,
) -> SpawnBuilderWithoutAddress<'_, A, impl FnOnce() -> A>where
A: Actor,
Prepare an actor to be spawned. Returns a SpawnBuilderWithoutAddress
which has to be further configured before spawning the actor.
Sourcepub fn prepare_fn<A, F>(
&mut self,
factory: F,
) -> SpawnBuilderWithoutAddress<'_, A, F>
pub fn prepare_fn<A, F>( &mut self, factory: F, ) -> SpawnBuilderWithoutAddress<'_, A, F>
Similar to prepare, but an actor factory is passed instead
of an Actor itself. This is used when an actor needs to be
created on its own thread instead of the calling thread.
Returns a SpawnBuilderWithoutAddress which has to be further
configured before spawning the actor.
Sourcepub fn spawn<A>(&mut self, actor: A) -> Result<Addr<A>, ActorError>
pub fn spawn<A>(&mut self, actor: A) -> Result<Addr<A>, ActorError>
Spawn a normal Actor in the system, returning its address when successful.
This address is created by the system and uses a default capacity.
If you need to customize the address see [prepare] or [prepare_fn] above.
Sourcepub fn run(&mut self) -> Result<(), ActorError>
pub fn run(&mut self) -> Result<(), ActorError>
Block the current thread until the system is shutdown.
Methods from Deref<Target = SystemHandle>§
Sourcepub fn shutdown(&self) -> Result<(), ActorError>
pub fn shutdown(&self) -> Result<(), ActorError>
Stops all actors spawned by this system.
Sourcepub fn subscribe_recipient<M: 'static, E: Event + Into<M>>(
&self,
recipient: Recipient<M>,
)
pub fn subscribe_recipient<M: 'static, E: Event + Into<M>>( &self, recipient: Recipient<M>, )
Subscribe given recipient to events of type E. See Context::subscribe().
Sourcepub fn subscribe_and_receive_latest<M: 'static, E: Event + Into<M>>(
&self,
recipient: Recipient<M>,
) -> Result<(), SendError>
pub fn subscribe_and_receive_latest<M: 'static, E: Event + Into<M>>( &self, recipient: Recipient<M>, ) -> Result<(), SendError>
Subscribe given recipient to events of type E and send the last cached event to it.
See Context::subscribe_and_receive_latest().
Sourcepub fn publish<E: Event>(&self, event: E) -> Result<(), PublishError>
pub fn publish<E: Event>(&self, event: E) -> Result<(), PublishError>
Publish an event. All actors that have previously subscribed to the type will receive it.
The event will be also cached. Actors that will subscribe to the type in future may choose to receive the last cached event upon subscription.
When sending to some subscriber fails, others are still tried and vec of errors is returned.
For direct, non-Clone or high-throughput messages please use Addr or Recipient.