Skip to main content

hexeract_core/
notification.rs

1/// Marker trait for messages announcing that something happened, with fan-out
2/// semantics: zero or more handlers may react to the same notification.
3///
4/// Unlike [`crate::Command`] and [`crate::Query`], a notification has no
5/// output and is not expected to be answered. It is broadcast to every
6/// handler registered for its type.
7///
8/// The mediator shares a single `Arc<N>` across every handler, so the value is
9/// never deep-cloned per handler and `Notification` does not require `Clone`.
10/// A handler that needs an owned copy can clone out of the `Arc` itself.
11///
12/// # Example
13///
14/// ```
15/// use hexeract_core::Notification;
16///
17/// struct OrderShipped {
18///     pub order_id: uuid::Uuid,
19/// }
20///
21/// impl Notification for OrderShipped {}
22/// ```
23pub trait Notification: Send + Sync + 'static {}