[−][src]Struct riker::actor::Props
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.
Methods
impl Props
[src]
pub fn new<A, F>(creator: F) -> Arc<Mutex<impl ActorProducer<Actor = A>>> where
A: Actor + Send + 'static,
F: Fn() -> A + Send + 'static,
[src]
A: Actor + Send + 'static,
F: Fn() -> A + Send + 'static,
Creates an ActorProducer
with no factory method parameters.
Examples
struct User; impl User { fn actor() -> Self { User } } // main let sys = ActorSystem::new().unwrap(); let props = Props::new(User::actor); // start the actor and get an `ActorRef` let actor = sys.actor_of(props, "user").unwrap();
pub fn new_args<A, Args, F>(
creator: F,
args: Args
) -> Arc<Mutex<impl ActorProducer<Actor = A>>> where
A: Actor + Send + 'static,
Args: ActorArgs + 'static,
F: Fn(Args) -> A + Send + 'static,
[src]
creator: F,
args: Args
) -> Arc<Mutex<impl ActorProducer<Actor = A>>> where
A: Actor + Send + 'static,
Args: ActorArgs + 'static,
F: Fn(Args) -> A + Send + 'static,
Creates an ActorProducer
with one or more factory method parameters.
Examples
An actor requiring a single parameter.
struct User { name: String, } impl User { fn actor(name: String) -> Self { User { name } } } // main let sys = ActorSystem::new().unwrap(); let props = Props::new_args(User::actor, "Naomi Nagata".into()); let actor = sys.actor_of(props, "user").unwrap();
An actor requiring multiple parameters.
struct BankAccount { name: String, number: String, } impl BankAccount { fn actor((name, number): (String, String)) -> Self { BankAccount { name, number } } } // main let sys = ActorSystem::new().unwrap(); let props = Props::new_args(BankAccount::actor, ("James Holden".into(), "12345678".into())); // start the actor and get an `ActorRef` let actor = sys.actor_of(props, "bank_account").unwrap();
Auto Trait Implementations
impl Unpin for Props
impl Sync for Props
impl Send for Props
impl UnwindSafe for Props
impl RefUnwindSafe for Props
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for 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<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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,