| Crates.io | notizia |
| lib.rs | notizia |
| version | 0.2.0 |
| created_at | 2025-12-26 17:23:24.078575+00 |
| updated_at | 2026-01-21 02:17:37.954833+00 |
| description | Frictionless message passing for the Tokio runtime |
| homepage | |
| repository | https://github.com/H1ghBre4k3r/notizia |
| max_upload_size | |
| id | 2005957 |
| size | 15,252 |
This crate provides the core runtime and traits for the Notizia message passing system. It is designed to make async task communication in Rust feel almost synchronous in its simplicity, while retaining the non-blocking nature of Tokio.
#[Task] attribute macro) that defines a message-handling process. The macro and trait share the same name, following the pattern of #[derive(Debug)] for the Debug trait.spawn!, send!, and recv! provide a shorthand DSL for interacting with processes.Define your state struct and message enum, then implement Runnable. The #[Task] attribute macro generates the Task trait implementation and necessary boilerplate to wire up the channels.
use notizia::{Task, Runnable, recv, send, spawn};
// The procedural macro generates the mailbox and Task trait implementation
#[Task(Message)]
struct MyProcess {}
// Clone is required for messages passed through channels
#[derive(Debug, Clone)]
enum Message {
Ping,
Pong,
}
impl Runnable<Message> for MyProcess {
async fn start(&self) {
// This block runs in the spawned task
loop {
let msg = recv!(self);
println!("Received: {:?}", msg);
// Handle exit conditions or logic here
}
}
}
#[tokio::main]
async fn main() {
let process = MyProcess {};
// Spawns the task and returns a handle
let handle = spawn!(process);
// Sends a message to the running task
if let Err(e) = send!(handle, Message::Ping) {
eprintln!("Failed to send message: {}", e);
}
// Wait for the task to complete
handle.join().await;
}