Skip to main content

Props

Struct Props 

Source
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

Source

pub fn new_no_args<A, F>( creator: F, ) -> Arc<Mutex<impl ActorProducer<Actor = A>>>
where A: Actor + Send + 'static, F: Fn() -> A + Send + 'static,

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();
Source

pub fn new_args<A, Args, F>( creator: F, args: Args, ) -> Arc<Mutex<impl ActorProducer<Actor = A>>>
where A: Actor + Send + 'static, Args: ActorArgs, 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 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> SendSyncUnwindSafe for T
where T: Send + Sync + UnwindSafe + ?Sized,