Skip to main content

Crate runact

Crate runact 

Source
Expand description

Runact — a Rust-native actor runtime.

Runact combines BEAM-style lightweight processes, messaging, scheduling and supervision with Rust’s ownership model.

§Quick Start

use runact::{Actor, ActorId, ActorContext, ActorError, Runtime};

struct Greeter;

impl Actor for Greeter {
    type Message = String;

    fn handle(&mut self, msg: String, ctx: &mut ActorContext) -> Result<(), ActorError> {
        println!("Hello, {}!", msg);
        Ok(())
    }
}

let mut runtime = Runtime::new().unwrap();
let id = runtime.spawn(Greeter).unwrap();
runtime.send(id, "world".to_string()).unwrap();

§Core Concepts

  • Actors — isolated units of state and behavior that communicate via messages.
  • Runtime — the top-level coordinator that spawns actors and routes messages.
  • Supervision — fault tolerance via configurable restart strategies.
  • Compute — a thread pool for CPU-intensive work off the actor scheduler.
  • Async tasks — a native executor for standard Rust Futures with task handles.
  • Timers — scheduled one-shot and periodic message delivery.
  • Resources — type-safe capability-based resource management.
  • Hot code loading — upgrade running actors without stopping the runtime (feature-gated).

Re-exports§

pub use actor::Actor;
pub use actor::ActorContext;
pub use actor::ActorError;
pub use actor::ActorId;
pub use error::RuntimeError;
pub use resource::Capability;
pub use resource::ResourceHandle;
pub use resource::ResourceRegistry;
pub use timer::Timer;
pub use timer::TimerConfig;
pub use timer::TimerId;

Modules§

actor
Actor trait and ActorId.
error
net
Networking primitives for runact.
process
resource
timer
Timer — scheduled message delivery.

Structs§

ActorInfo
Information about a spawned actor.
CancellationToken
ChildSpec
Child specification.
ComputeConfig
Configuration for the compute scheduler.
ComputeHandle
Handle to a submitted compute task. Used to retrieve the result or cancel the task.
ComputeScheduler
Thread pool for executing CPU-intensive tasks off the actor scheduler.
RequestHandle
Handle to a pending request. Receives the reply asynchronously.
Runtime
Top-level runtime coordinator.
RuntimeConfig
Runtime configuration.
RuntimeSender
Clonable handle for sending messages to actors from external threads.
RuntimeStats
Snapshot of runtime statistics.
Scheduler
SleepFuture
Future that completes after a specified duration.
Supervisor
Supervisor — manages child actor lifecycle.
TaskGroup
TaskHandle
Handle to a spawned async task.
TaskId
Unique identifier for an async task.
TimeoutFuture
Future that completes with a timeout.

Enums§

ComputeError
Errors that can occur during compute task submission or execution.
RestartPolicy
Restart policy for a child.
RestartStrategy
Strategy for restarting failed child actors.
TaskError
Errors that can occur while running or retrieving an async task.