Skip to main content

serenade_messenger/
message.rs

1//! Message marker traits for the sync bus.
2
3/// Envelope carried by the messenger bus.
4///
5/// `NAME` is the stable routing key used for handler registration and dispatch.
6pub trait Message: Send + Sync + 'static {
7    /// Stable message name (for example `cart.place_order`).
8    const NAME: &'static str;
9
10    /// Returns [`Self::NAME`].
11    fn name(&self) -> &'static str {
12        Self::NAME
13    }
14}
15
16/// Mutation with exactly one handler.
17pub trait Command: Message {}
18
19/// Notification with zero or more handlers (fan-out).
20pub trait Event: Message {}