Skip to main content

NoticeStore

Struct NoticeStore 

Source
pub struct NoticeStore { /* private fields */ }
Expand description

The last notices raised, oldest first, at most NoticeStore::bound and none older than NoticeStore::max_age_ms, whichever keeps fewer: the oldest goes when a new one comes past the bound, and NoticeStore::prune drops the old ones. An error not seen yet stays until it is seen, past both. Seen and resolved notices are marked; dismissed ones leave.

Implementations§

Source§

impl NoticeStore

Source

pub const DEFAULT_BOUND: usize = 500

How many notices a store keeps by default.

Source

pub const DEFAULT_MAX_AGE_MS: u64

How old a notice a store keeps by default: 30 days, in milliseconds.

Source

pub fn new(bound: usize) -> Self

A store keeping at most bound notices (at least one), for NoticeStore::DEFAULT_MAX_AGE_MS.

Source

pub fn with_max_age(self, max_age_ms: u64) -> Self

Keeping notices for max_age_ms milliseconds.

Source

pub fn bound(&self) -> usize

Source

pub fn set_limits(&mut self, bound: usize, max_age_ms: u64)

Keeps at most bound notices (at least one), none older than max_age_ms (errors not seen yet aside), from now on.

Source

pub fn max_age_ms(&self) -> u64

How old a notice it keeps, in milliseconds.

Source

pub fn rev(&self) -> u64

A number that changes whenever what it keeps changes (to save it when it moved).

Source

pub fn next_id(&mut self) -> NoticeId

The id the next notice raised without one gets.

Source

pub fn add(&mut self, notice: Notice)

Keeps notice (one with the same id is replaced, in its place); the oldest leaves past the bound, unless it is an error not seen yet.

Source

pub fn prune(&mut self, now_ms: u64) -> usize

Drops the notices older than NoticeStore::max_age_ms at now_ms (milliseconds since 1970), errors not seen yet aside; how many it dropped.

Source

pub fn resolve(&mut self, ids: &[NoticeId]) -> usize

Marks ids resolved; how many it held.

Source

pub fn see(&mut self, ids: &[NoticeId]) -> usize

Marks ids seen; how many it held.

Source

pub fn dismiss(&mut self, ids: &[NoticeId]) -> usize

Drops ids; how many it held.

Source

pub fn get(&self, id: &NoticeId) -> Option<&Kept>

A notice kept, by id.

Source

pub fn list(&self) -> impl Iterator<Item = &Kept>

The notices kept, oldest first.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn to_doc(&self) -> NoticesDoc

What it keeps, as its document (routes left empty).

Source

pub fn restore(&mut self, doc: &NoticesDoc, now_ms: u64)

Takes back the notices of a document saved before: they come first, oldest first, then the ones kept since (a saved one with the same id gives way to the one kept since); the next id goes past both; then the bound and the age at now_ms apply.

Trait Implementations§

Source§

impl Clone for NoticeStore

Source§

fn clone(&self) -> NoticeStore

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for NoticeStore

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for NoticeStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.