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
impl NoticeStore
Sourcepub const DEFAULT_BOUND: usize = 500
pub const DEFAULT_BOUND: usize = 500
How many notices a store keeps by default.
Sourcepub const DEFAULT_MAX_AGE_MS: u64
pub const DEFAULT_MAX_AGE_MS: u64
How old a notice a store keeps by default: 30 days, in milliseconds.
Sourcepub fn new(bound: usize) -> Self
pub fn new(bound: usize) -> Self
A store keeping at most bound notices (at least one), for
NoticeStore::DEFAULT_MAX_AGE_MS.
Sourcepub fn with_max_age(self, max_age_ms: u64) -> Self
pub fn with_max_age(self, max_age_ms: u64) -> Self
Keeping notices for max_age_ms milliseconds.
pub fn bound(&self) -> usize
Sourcepub fn set_limits(&mut self, bound: usize, max_age_ms: u64)
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.
Sourcepub fn max_age_ms(&self) -> u64
pub fn max_age_ms(&self) -> u64
How old a notice it keeps, in milliseconds.
Sourcepub fn rev(&self) -> u64
pub fn rev(&self) -> u64
A number that changes whenever what it keeps changes (to save it when it moved).
Sourcepub fn add(&mut self, notice: Notice)
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.
Sourcepub fn prune(&mut self, now_ms: u64) -> usize
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.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn to_doc(&self) -> NoticesDoc
pub fn to_doc(&self) -> NoticesDoc
What it keeps, as its document (routes left empty).
Sourcepub fn restore(&mut self, doc: &NoticesDoc, now_ms: u64)
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
impl Clone for NoticeStore
Source§fn clone(&self) -> NoticeStore
fn clone(&self) -> NoticeStore
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more