pub struct EventSeqTracker<const N: usize> { /* private fields */ }Expand description
The last seq accepted on each event channel of one session, and the loss
each new occurrence reveals (ridl §3.1; frame specification §5.2 and §7).
The sequence counter of an event is per channel, per provider instance, and
starts over with each session (frame specification §3, §7). A channel is
one (InterfaceNo, Ordinal) in the session’s catalog, so the tracker keys
on that pair and never on the interface alone: two channels of one
interface whose occurrences interleave are not a loss. One tracker serves
one session, and so one provider instance; a consumer holding several
sessions holds one tracker for each, and a new session starts with a new
tracker.
The storage is the caller’s: N slots, one per channel, held inline with
no allocation. A channel that finds no free slot is refused with
TrackerFull; forget frees a slot, for example when
the consumer unsubscribes (frame specification §6.2).
Feed the tracker every occurrence the channel accepts, in the order received. A loss is a gap between two accepted occurrences of one channel (frame specification §5.2, §7, which attribute it to ridl §3.1).
Implementations§
Source§impl<const N: usize> EventSeqTracker<N>
impl<const N: usize> EventSeqTracker<N>
Sourcepub fn observe(
&mut self,
interface: InterfaceNo,
ordinal: Ordinal,
seq: u64,
) -> Result<Continuity, TrackerFull>
pub fn observe( &mut self, interface: InterfaceNo, ordinal: Ordinal, seq: u64, ) -> Result<Continuity, TrackerFull>
Records seq as the latest occurrence on the channel
(interface, ordinal) and reports what it reveals.
The first occurrence on a channel takes a free slot and reports
Continuity::First. A later one reports Continuity::Next or
Continuity::Lost and becomes the channel’s last seq, or reports
Continuity::NotNewer and leaves the last seq as it was.
§Errors
TrackerFull when the channel is not tracked and no slot is free.
Every tracked channel is unchanged.
Sourcepub fn forget(&mut self, interface: InterfaceNo, ordinal: Ordinal)
pub fn forget(&mut self, interface: InterfaceNo, ordinal: Ordinal)
Stops tracking the channel (interface, ordinal) and frees its slot.
The next occurrence on that channel reports Continuity::First. A
channel the tracker does not hold is left alone.