Skip to main content

AlertManager

Struct AlertManager 

Source
pub struct AlertManager<P: AlertPolicy> { /* private fields */ }
Expand description

Standing alerts under a policy.

Stores up to MAX_ALERTS alerts inline, ordered by priority then by time raised, so AlertManager::alerts starts with the most pressing. Several kilobytes: keep it behind a reference or in a static. Deliberately not Copy, so the board cannot be duplicated by accident:

ⓘ
fn is_copy<T: Copy>() {}
is_copy::<kinavis_alerts::AlertManager<kinavis_alerts::StandardPolicy>>();

Implementations§

Source§

impl<P: AlertPolicy> AlertManager<P>

Source

pub fn new(policy: P) -> Self

Empty board under policy.

Source

pub const fn policy(&self) -> &P

Policy.

Source

pub fn alerts(&self) -> &[Alert]

Standing alerts, most pressing first (priority, then time raised).

Source

pub const fn len(&self) -> usize

Number of standing alerts.

Source

pub const fn is_empty(&self) -> bool

Whether no alert is standing.

Source

pub fn alert(&self, id: AlertId) -> Option<&Alert>

Alert by identifier, if standing.

Source

pub fn unacknowledged(&self) -> impl Iterator<Item = &Alert> + '_

Unacknowledged alerts, most pressing first.

Source

pub fn highest(&self) -> Option<&Alert>

Most pressing standing alert, if any.

Source

pub fn ingest<E: Reportable>( &mut self, events: &[E], now: Instant<Utc>, ) -> AlertChanges

Processes the events of one operation at now.

Each event first ends the conditions it ends, then raises or repeats its own alert; conditions not reported within rectify_after are then rectified as in AlertManager::tick. Accepts a slice of any Reportable type — any EventList dereferences to one. Typically one call per source list: estimator, guidance, traffic.

Source

pub fn tick(&mut self, now: Instant<Utc>) -> AlertChanges

Advances time: conditions not reported within rectify_after are rectified — removed if acknowledged, otherwise left as AlertState::Rectified.

Source

pub fn acknowledge( &mut self, id: AlertId, at: Instant<Utc>, ) -> Result<AlertChanges>

Acknowledges an alert: active becomes acknowledged, rectified is removed.

§Errors

KernelError::OutOfRange if no alert has that identifier.

Source

pub fn acknowledge_all(&mut self, at: Instant<Utc>) -> AlertChanges

Acknowledges every standing alert.

Trait Implementations§

Source§

impl<P: Clone + AlertPolicy> Clone for AlertManager<P>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: Debug + AlertPolicy> Debug for AlertManager<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<P> Freeze for AlertManager<P>
where P: Freeze,

§

impl<P> RefUnwindSafe for AlertManager<P>
where P: RefUnwindSafe,

§

impl<P> Send for AlertManager<P>
where P: Send,

§

impl<P> Sync for AlertManager<P>
where P: Sync,

§

impl<P> Unpin for AlertManager<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for AlertManager<P>
where P: UnsafeUnpin,

§

impl<P> UnwindSafe for AlertManager<P>
where P: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.