pub struct System(_);

Implementations

Create a new System using the provided config.

The config with which this System was created.

Spawn an actor

Example:

use agner_actors::{System, Context, Event};

async fn actor_behaviour(context: &mut Context<&'static str>, actor_name: &'static str) {
    loop {
        if let Event::Message(message) = context.next_event().await {
            eprintln!("[{}] received: {}", actor_name, message);
        }
    }
}
let _ = async {
    let system = System::new(Default::default());

    let alice = system.spawn(actor_behaviour, "Alice", Default::default()).await.expect("Failed to spawn an actor");
    let bob = system.spawn(actor_behaviour, "Bob", Default::default()).await.expect("Failed to spawn an actor");
};

Send SigExit to the specified actor.

Wait for the specified actor to terminate, and return upon its termination the [ExitReason]. In case the actor with the specified actor_id does not exist — return [ExitReason::NoProcess] right away.

Send a single message to the specified actor.

Open a channel to the specified actor.

Link two actors

Associate arbitrary data with the specified actor. Upon actor termination that data will be dropped. If no actor with the specified id exists, the data will be dropped right away.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.