pub struct EventStore<const C: usize, const I: usize, const D: usize> { /* private fields */ }Expand description
The node’s event store: one ring per priority (§7.14.2).
Event records SHALL be buffered on the Node, with priority given to events of a higher priority level over a lower priority level.
Separate buffers rather than one shared ring with a priority field, because that sentence
is a guarantee: a flood of Debug records must not be able to push out a Critical one,
and in a shared ring it always can. The sizes are the caller’s, so a device that logs
heavily at Debug pays for it only there.
Implementations§
Source§impl<const C: usize, const I: usize, const D: usize> EventStore<C, I, D>
impl<const C: usize, const I: usize, const D: usize> EventStore<C, I, D>
Sourcepub const fn new(numbers: EventNumbers) -> Self
pub const fn new(numbers: EventNumbers) -> Self
An empty store resuming from a counter.
Sourcepub const fn numbers(&self) -> EventNumbers
pub const fn numbers(&self) -> EventNumbers
The event-number counter.
Sourcepub const fn reserved(&mut self, value: u64)
pub const fn reserved(&mut self, value: u64)
Records that a reservation has been durably stored (§7.14.1.1 step 2).
Sourcepub fn record(&mut self, event: &NewEvent<'_>) -> Result<u64, RecordError>
pub fn record(&mut self, event: &NewEvent<'_>) -> Result<u64, RecordError>
Records an event, assigning it the next number.
Sourcepub const fn buffer(&self, priority: EventPriority) -> &dyn BufferView
pub const fn buffer(&self, priority: EventPriority) -> &dyn BufferView
The buffer for one priority.
Sourcepub fn matching<'a>(
&'a self,
path: &'a EventPath,
accessing: Option<FabricIndex>,
min_number: u64,
) -> impl Iterator<Item = &'a EventRecord>
pub fn matching<'a>( &'a self, path: &'a EventPath, accessing: Option<FabricIndex>, min_number: u64, ) -> impl Iterator<Item = &'a EventRecord>
Every buffered record matching path, visible to accessing, with a number at or
above min_number, in event-number order.
§8.5: “Each Report containing events SHALL deliver queued events without reordering the
queue.” Across priorities that means by number, because the number is the order things
happened in — reporting all the Critical records before all the Info ones would
hand a client a log that contradicts itself.
Sourcepub fn prune_below(&mut self, number: u64)
pub fn prune_below(&mut self, number: u64)
Forgets every record below number, across every priority.
Trait Implementations§
Source§impl<const C: usize, const I: usize, const D: usize> EventSource for EventStore<C, I, D>
impl<const C: usize, const I: usize, const D: usize> EventSource for EventStore<C, I, D>
Source§fn each_matching(
&self,
path: &EventPath,
accessing: Option<FabricIndex>,
min_number: u64,
each: &mut dyn FnMut(&EventRecord) -> bool,
)
fn each_matching( &self, path: &EventPath, accessing: Option<FabricIndex>, min_number: u64, each: &mut dyn FnMut(&EventRecord) -> bool, )
path, visible to accessing, whose number is at least
min_number — in event-number order, which §8.5 requires: “Each Report containing
events SHALL deliver queued events without reordering the queue.” Read more