pub struct Props;Expand description
Provides instances of ActorProducer for use when creating Actors (actor_of).
Actors are not created directly. Instead you provide an ActorProducer
that allows the ActorSystem to start an actor when actor_of is used,
or when an actor fails and a supervisor requests an actor to be restarted.
ActorProducer can hold values required by the actor’s factory method
parameters.
Implementations§
Source§impl Props
impl Props
Sourcepub fn new_no_args<A, F>(
creator: F,
) -> Arc<Mutex<impl ActorProducer<Actor = A>>>
pub fn new_no_args<A, F>( creator: F, ) -> Arc<Mutex<impl ActorProducer<Actor = A>>>
Creates an ActorProducer with no factory method parameters.
§Examples
#[derive(Default)]
struct User;
// main
let sys = ActorSystem::new().unwrap();
// start the actor and get an `ActorRef`
let actor = sys.actor_of::<User>("user").unwrap();Sourcepub fn new_args<A, Args, F>(
creator: F,
args: Args,
) -> Arc<Mutex<impl ActorProducer<Actor = A>>>
pub fn new_args<A, Args, F>( creator: F, args: Args, ) -> Arc<Mutex<impl ActorProducer<Actor = A>>>
Creates an ActorProducer with one or more factory method parameters.
§Examples
An actor requiring a single parameter.
struct User {
name: String,
}
impl ActorFactoryArgs<String> for User {
fn create_args(name: String) -> Self {
User { name }
}
}
// main
let sys = ActorSystem::new().unwrap();
let actor = sys.actor_of_args::<User, _>("user", "Naomi Nagata".into()).unwrap();An actor requiring multiple parameters.
struct BankAccount {
name: String,
number: String,
}
impl ActorFactoryArgs<(String, String)> for BankAccount {
fn create_args((name, number): (String, String)) -> Self {
BankAccount { name, number }
}
}
// main
let sys = ActorSystem::new().unwrap();
// start the actor and get an `ActorRef`
let actor = sys.actor_of_args::<BankAccount, _>("bank_account", ("James Holden".into(), "12345678".into())).unwrap();Auto Trait Implementations§
impl Freeze for Props
impl RefUnwindSafe for Props
impl Send for Props
impl Sync for Props
impl Unpin for Props
impl UnsafeUnpin for Props
impl UnwindSafe for Props
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more