pub struct NotificationRouting(/* private fields */);Expand description
Priority-based routing table read from the notification-routing:
section of ~/.ao-rs/config.yaml.
On-disk YAML:
notification-routing:
urgent: [stdout, ntfy]
action: [stdout, ntfy]
warning: [stdout]
info: [stdout]Stored as a newtype around HashMap<EventPriority, Vec<String>>
with #[serde(transparent)] so the on-disk form is just the map —
no wrapper key. Hiding the inner HashMap behind names_for keeps
the public API stable if we later want to change the container or
bolt on a per-reaction-key override layer.
Default: empty map. An empty table means “nothing configured for
any priority” — NotifierRegistry::resolve warn-onces per priority
on the first miss and drops the notification. The fallback policy
(default-to-stdout when the table is empty) belongs one layer up
at the ao-cli wiring site in Phase C, not inside the config
type itself, so this module stays pure data.
Implementations§
Source§impl NotificationRouting
impl NotificationRouting
Sourcepub fn names_for(&self, priority: EventPriority) -> Option<&[String]>
pub fn names_for(&self, priority: EventPriority) -> Option<&[String]>
Return the list of notifier names registered for this priority,
or None if the priority has no entry.
An empty list (priority present but points at []) is returned
as Some(&[]) — distinct from a missing entry. The registry’s
resolve method folds both cases together (warn-once + empty
result) so callers don’t need to branch on the difference, but
they CAN if they ever want to.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
True if the routing table has no priorities configured at all.
The ao-cli wiring uses this in Phase C to decide whether to
apply the “default to stdout for everything” fallback.
Sourcepub fn from_map(map: HashMap<EventPriority, Vec<String>>) -> Self
pub fn from_map(map: HashMap<EventPriority, Vec<String>>) -> Self
Construct a routing table from a pre-built map. Used by
ao-cli to build the default-to-stdout routing when the user’s
config has no notification-routing: section, and by unit tests
that want an inline table without going through serde.
Trait Implementations§
Source§impl Clone for NotificationRouting
impl Clone for NotificationRouting
Source§fn clone(&self) -> NotificationRouting
fn clone(&self) -> NotificationRouting
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NotificationRouting
impl Debug for NotificationRouting
Source§impl Default for NotificationRouting
impl Default for NotificationRouting
Source§fn default() -> NotificationRouting
fn default() -> NotificationRouting
Source§impl<'de> Deserialize<'de> for NotificationRouting
impl<'de> Deserialize<'de> for NotificationRouting
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for NotificationRouting
impl PartialEq for NotificationRouting
Source§impl Serialize for NotificationRouting
impl Serialize for NotificationRouting
impl Eq for NotificationRouting
impl StructuralPartialEq for NotificationRouting
Auto Trait Implementations§
impl Freeze for NotificationRouting
impl RefUnwindSafe for NotificationRouting
impl Send for NotificationRouting
impl Sync for NotificationRouting
impl Unpin for NotificationRouting
impl UnsafeUnpin for NotificationRouting
impl UnwindSafe for NotificationRouting
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.