MCPcopy Index your code
hub / github.com/Diggsey/act-zero

github.com/Diggsey/act-zero @0.4.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.4.0 ↗ · + Follow
120 symbols 215 edges 15 files 41 documented · 34%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

act-zero

An actor system for Rust, designed with several goals in mind:

  • No boilerplate.
  • Ergonomic.
  • Supports standard trait-based static and dynamic polymorphism.
  • Embraces async/await.
  • Executor agnostic.

Very little code is required to get started:

use std::error::Error;

use futures::executor::LocalPool;
use act_zero::*;

struct SimpleGreeter {
    number_of_greets: i32,
}

impl Actor for SimpleGreeter {}

impl SimpleGreeter {
    async fn greet(&mut self, name: String) -> ActorResult<String> {
        self.number_of_greets += 1;
        Produces::ok(format!(
            "Hello, {}. You are number {}!",
            name, self.number_of_greets
        ))
    }
}

fn main() -> Result<(), Box<dyn Error>> {
    let mut pool = LocalPool::new();
    let spawner = pool.spawner();
    pool.run_until(async move {
        let actor_ref = Addr::new(
            &spawner,
            SimpleGreeter {
                number_of_greets: 0,
            },
        )?;

        let greeting = call!(actor_ref.greet("John".into())).await?;
        println!("{}", greeting);

        let greeting = call!(actor_ref.greet("Emma".into())).await?;
        println!("{}", greeting);
        Ok(())
    })
}

See the examples folder for more varied uses.

Extension points exported contracts — how you extend this code

Actor (Interface)
(no doc) [11 implementers]
src/actor.rs
AsAddr (Interface)
Implemented by addresses and references to addresses [3 implementers]
src/addr.rs
SupportsTimers (Interface)
Timers can be used on runtimes implementing this trait. [3 implementers]
src/timer.rs
IntoActorResult (Interface)
Actor methods may return any type implementing this trait. [2 implementers]
src/actor.rs
AddrLike (Interface)
Trait provides methods for spawning futures onto an actor. Implemented by `Addr` and `WeakAddr` alike. [2 implementers]
src/addr.rs
Tick (Interface)
(no doc) [3 implementers]
src/timer.rs

Core symbols most depended-on inside this repo

ptr
called by 22
src/addr.rs
clone
called by 8
src/addr.rs
spawn_actor
called by 8
src/runtimes/tokio.rs
send_fut
called by 6
src/addr.rs
upgrade_weak
called by 4
src/addr.rs
set_timeout_internal
called by 4
src/timer.rs
run_with_timeout_internal
called by 4
src/timer.rs
delay
called by 4
src/runtimes/tokio.rs

Shape

Method 72
Function 21
Class 18
Interface 6
Enum 3

Languages

Rust100%

Modules by API surface

src/timer.rs30 symbols
src/addr.rs30 symbols
src/runtimes/tokio.rs15 symbols
src/runtimes/async_std.rs10 symbols
src/actor.rs8 symbols
examples/using_timers/main.rs5 symbols
src/runtimes/panic.rs4 symbols
examples/using_provided_runtime/main.rs4 symbols
examples/using_global_runtime/main.rs4 symbols
examples/using_tokio/main.rs3 symbols
examples/using_async_std/main.rs3 symbols
src/utils.rs2 symbols

For agents

$ claude mcp add act-zero \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact