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
Futureswith 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§
- Actor
Info - Information about a spawned actor.
- Cancellation
Token - Child
Spec - Child specification.
- Compute
Config - Configuration for the compute scheduler.
- Compute
Handle - Handle to a submitted compute task. Used to retrieve the result or cancel the task.
- Compute
Scheduler - Thread pool for executing CPU-intensive tasks off the actor scheduler.
- Request
Handle - Handle to a pending request. Receives the reply asynchronously.
- Runtime
- Top-level runtime coordinator.
- Runtime
Config - Runtime configuration.
- Runtime
Sender - Clonable handle for sending messages to actors from external threads.
- Runtime
Stats - Snapshot of runtime statistics.
- Scheduler
- Sleep
Future - Future that completes after a specified duration.
- Supervisor
- Supervisor — manages child actor lifecycle.
- Task
Group - Task
Handle - Handle to a spawned async task.
- TaskId
- Unique identifier for an async task.
- Timeout
Future - Future that completes with a timeout.
Enums§
- Compute
Error - Errors that can occur during compute task submission or execution.
- Restart
Policy - Restart policy for a child.
- Restart
Strategy - Strategy for restarting failed child actors.
- Task
Error - Errors that can occur while running or retrieving an async task.