pub struct AlertBus { /* private fields */ }Expand description
Central alert bus.
Components fire alerts via AlertBus::fire; subscribers receive them
synchronously in the same call.
§Example
use obs_core::bus::AlertBus;
let bus = AlertBus::new();
assert_eq!(bus.subscriber_count(), 0);Implementations§
Source§impl AlertBus
impl AlertBus
pub fn with_history_limit(limit: usize) -> Self
Sourcepub fn subscribe(
&mut self,
handler: Box<dyn AlertHandler>,
min_severity: AlertSeverity,
source: Option<String>,
)
pub fn subscribe( &mut self, handler: Box<dyn AlertHandler>, min_severity: AlertSeverity, source: Option<String>, )
Register a handler that receives all alerts at or above min_severity.
If source is Some, only alerts from that source component are delivered.
Sourcepub fn fire(&mut self, alert: Alert)
pub fn fire(&mut self, alert: Alert)
Dispatch alert to all matching subscribers and add it to history.
Sourcepub fn history_at_or_above(
&self,
min: AlertSeverity,
) -> impl Iterator<Item = &Alert>
pub fn history_at_or_above( &self, min: AlertSeverity, ) -> impl Iterator<Item = &Alert>
History filtered to severity >= min.
Sourcepub fn history_for_source<'a>(
&'a self,
source: &str,
) -> impl Iterator<Item = &'a Alert>
pub fn history_for_source<'a>( &'a self, source: &str, ) -> impl Iterator<Item = &'a Alert>
History filtered to a single source.
pub fn subscriber_count(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AlertBus
impl !RefUnwindSafe for AlertBus
impl Send for AlertBus
impl !Sync for AlertBus
impl Unpin for AlertBus
impl UnsafeUnpin for AlertBus
impl !UnwindSafe for AlertBus
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
Mutably borrows from an owned value. Read more