pub trait Spawn<S, NA, RT>: PrivateSpawn<S, NA, RT> {
fn try_spawn(
&mut self,
supervisor: S,
new_actor: NA,
arg: NA::Argument,
options: ActorOptions
) -> Result<ActorRef<NA::Message>, NA::Error>
where
S: Supervisor<NA>,
NA: NewActor<RuntimeAccess = RT>,
{ ... }
fn spawn(
&mut self,
supervisor: S,
new_actor: NA,
arg: NA::Argument,
options: ActorOptions
) -> ActorRef<NA::Message>
where
S: Supervisor<NA>,
NA: NewActor<Error = !, RuntimeAccess = RT>,
{ ... }
}Expand description
The Spawn trait defines how new actors are added to the runtime.
Provided Methods
fn try_spawn(
&mut self,
supervisor: S,
new_actor: NA,
arg: NA::Argument,
options: ActorOptions
) -> Result<ActorRef<NA::Message>, NA::Error> where
S: Supervisor<NA>,
NA: NewActor<RuntimeAccess = RT>,
fn try_spawn(
&mut self,
supervisor: S,
new_actor: NA,
arg: NA::Argument,
options: ActorOptions
) -> Result<ActorRef<NA::Message>, NA::Error> where
S: Supervisor<NA>,
NA: NewActor<RuntimeAccess = RT>,
Attempts to spawn an actor.
Arguments:
supervisor: all actors need supervision, thesupervisoris the supervisor for this actor, see theSupervisortrait for more information.new_actor: theNewActorimplementation that defines how to start the actor.arg: the argument(s) passed when starting the actor, andoptions: the actor options used to spawn the new actors.
When using a NewActor implementation that never returns an error,
such as the implementation provided by async functions, it’s easier to
use the spawn method.
fn spawn(
&mut self,
supervisor: S,
new_actor: NA,
arg: NA::Argument,
options: ActorOptions
) -> ActorRef<NA::Message> where
S: Supervisor<NA>,
NA: NewActor<Error = !, RuntimeAccess = RT>,
fn spawn(
&mut self,
supervisor: S,
new_actor: NA,
arg: NA::Argument,
options: ActorOptions
) -> ActorRef<NA::Message> where
S: Supervisor<NA>,
NA: NewActor<Error = !, RuntimeAccess = RT>,
Spawn an actor.
This is a convenience method for NewActor implementations that never
return an error, such as asynchronous functions.
See Spawn::try_spawn for more information.