#[event]Expand description
Attach to a payload struct to register it as a typed event.
The macro auto-derives Serialize, Deserialize, and JsonSchema
against the serde / schemars re-exports from coralstack-cmd-ipc,
so user crates don’t need to pull those dependencies into their own
Cargo.toml. It also emits the impl Event for the struct with the
id and wire-level schema.
Unit structs emit no payload on the wire — the natural way to declare a void event.
ⓘ
/// Worker has finished initializing.
#[event("worker.ready")]
pub struct WorkerReady {
pub worker_id: String,
pub command_count: u32,
}
// Void event — no payload on the wire.
#[event("worker.tick")]
pub struct WorkerTick;
// Emit with full type safety:
registry.emit(WorkerReady { worker_id: "w1".into(), command_count: 2 })?;
registry.emit(WorkerTick)?;
// Subscribe — callback receives a deserialized `WorkerReady`:
let _unsub = registry.on::<WorkerReady>(|event| {
println!("{} ready", event.worker_id);
});