| Crates.io | theta-macros |
| lib.rs | theta-macros |
| version | 0.1.0-alpha.40 |
| created_at | 2025-08-18 07:01:53.165154+00 |
| updated_at | 2025-09-22 03:58:49.292476+00 |
| description | Procedural macros for the Theta actor framework |
| homepage | |
| repository | https://github.com/cwahn/theta |
| max_upload_size | |
| id | 1800032 |
| size | 45,346 |
An async actor framework for Rust
Theta is an ergonomic yet minimal and performant async actor framework which Rust deserves.
tokio::task and two MPMC channels.ActorRef is just a MPMC sender.iroh.ActorRef could be passed around network boundary as regular data in message.remote.monitor.persistence.cargo add theta
use serde::{Deserialize, Serialize};
use theta::prelude::*;
#[derive(Debug, Clone, ActorArgs)]
struct Counter {
value: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Inc(i64);
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GetValue;
#[actor("96d9901f-24fc-4d82-8eb8-023153d41074")]
impl Actor for Counter {
type View = Nil;
// Behaviors will generate single enum Msg for the actor
const _: () = {
async |Inc(amount): Inc| { // Behavior can access &mut self
self.value += amount;
};
async |_: GetValue| -> i64 { // Behavior may or may not have return
self.value
};
};
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let ctx = RootContext::init_local();
let counter = ctx.spawn(Counter { value: 0 });
let _ = counter.tell(Inc(5)); // Fire-and-forget
let current = counter.ask(GetValue).await?; // Wait for response
println!("Current value: {current}"); // Current value: 5
Ok(())
}
Theta is currently under active development and API is subject to change. Not yet recommended for any serious business.
Result::Err implementing std::fmt::Display on tell to be logged as tracing::error! to prevent silent failure or code duplicationactor macro to take identifier as ActorIdLicensed under the MIT License.