Reference

API Overview

All the key types, traits, and macros in one place. For complete API documentation, see docs.rs/acton-reactive.

Core Types

ActonApp

The actor system runtime.

let runtime = ActonApp::launch_async().await;
MethodDescription
launch_async().awaitStart a new actor system
new_actor::<T>()Create an actor builder
new_actor_with_name::<T>(name)Create a named actor builder
shutdown_all().awaitGraceful shutdown
broker()Access the message broker
ipc_registry()Access IPC type registry
ipc_expose(name, handle)Expose actor for IPC
start_ipc_listener().awaitStart IPC listener

Actor Builder

Configures actors before spawning.

let handle = runtime
    .new_actor::<Counter>()
    .mutate_on::<Increment>(handler)
    .act_on::<GetCount>(handler)
    .start()
    .await;
MethodDescription
mutate_on::<M>(handler)Register state-changing handler
act_on::<M>(handler)Register read-only handler
before_start(hook)Lifecycle hook before start
after_stop(hook)Lifecycle hook after stop
expose_for_ipc()Expose actor for IPC using its name
start().awaitSpawn the actor
handle()Get handle before starting

ActorHandle

Reference to a running actor.

handle.send(Message).await;
handle.stop().await.ok();
MethodDescription
send(msg).awaitFire-and-forget message
stop().awaitStop the actor
subscribe::<M>().awaitSubscribe to broadcast messages
reply_address()Get address for replies
create_envelope(target)Create envelope for sending
supervise(child).awaitStart and supervise a child
id()Get actor's identifier

Reply

Handler return type.

MethodDescription
Reply::ready()Synchronous completion
Reply::pending(future)Async completion
Reply::try_ok(value)For fallible handlers

Envelope

Message wrapper with routing information.

MethodDescription
message()Access the message data
reply_envelope()Create envelope back to sender
new_envelope(&address)Create envelope to different recipient
send(msg).awaitSend via this envelope

Macros

#[acton_actor]

Marks a struct as actor state.

#[acton_actor]
struct Counter {
    count: i32,
}

#[acton_message]

Marks a struct as a message.

#[acton_message]
struct Increment;

#[acton_message(ipc)]  // Enable IPC serialization
struct GetValue;

#[acton_main]

Sets up the async runtime.

#[acton_main]
async fn main() {
    let runtime = ActonApp::launch_async().await;
    // ...
}

Prelude

Import everything:

use acton_reactive::prelude::*;

Includes: ActonApp, ActorHandle, Reply, all macros.

Previous
Integration