pub struct EventIndex { /* private fields */ }Expand description
The contribution set for one scope: contributions in first-seen order, deduplicated by event id (T005).
Inflating this type is deliberate — the count-mode fold (WP02) reads it once, so a contribution cannot be counted twice by being walked twice, and the dedupe lives here rather than at each caller.
Implementations§
Source§impl EventIndex
impl EventIndex
Sourcepub fn new(scope: AnalyticsScope) -> Self
pub fn new(scope: AnalyticsScope) -> Self
An empty index for a scope.
Sourcepub fn scope(&self) -> &AnalyticsScope
pub fn scope(&self) -> &AnalyticsScope
The scope every contribution in this index was classified against.
Sourcepub fn contribute(&mut self, event: AnalyticsEvent) -> Contribution
pub fn contribute(&mut self, event: AnalyticsEvent) -> Contribution
Contribute one event, reporting what happened.
The duplicate check covers ids already admitted and ids already refused for being outside the period, and it comes first; the period check comes second. So classifying one recorded event twice is inert whichever side of the period it fell on, and both counters measure recorded events rather than classifications.
Sourcepub fn contribute_history(
&mut self,
source_ref: &str,
history: &History,
) -> usize
pub fn contribute_history( &mut self, source_ref: &str, history: &History, ) -> usize
Contribute every parsed entry of a History section, returning how many were newly added.
The ordinal an event is identified by counts parsed events only: an unparseable line a human inserted occupies no ordinal, so it cannot renumber the events after it and two classifications of one file agree on every id. A line that was a readable event and was mangled into unreadability does still close up the ordinals behind it — see the module’s provenance note for why that is the accepted trade rather than a content hash.
Sourcepub fn events(&self) -> impl Iterator<Item = &AnalyticsEvent> + '_
pub fn events(&self) -> impl Iterator<Item = &AnalyticsEvent> + '_
The contributed events, in first-seen order.
Sourcepub fn of_class(
&self,
class: EventClass,
) -> impl Iterator<Item = &AnalyticsEvent> + '_
pub fn of_class( &self, class: EventClass, ) -> impl Iterator<Item = &AnalyticsEvent> + '_
The contributed events of one class, in first-seen order.
Sourcepub fn count_of(&self, class: EventClass) -> usize
pub fn count_of(&self, class: EventClass) -> usize
How many events of one class contributed.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the index holds no contribution at all — which is the honest answer for a project whose files carry no events, not an error.
Sourcepub fn duplicates(&self) -> usize
pub fn duplicates(&self) -> usize
How many repeated classifications the index rejected (C-002).
Sourcepub fn outside_period(&self) -> usize
pub fn outside_period(&self) -> usize
How many recorded events fell outside the scope’s period and were therefore not contributions — an event count, not a count of classifications, because an id already refused here is remembered (C-002). Coverage context: a non-zero count says the period excluded recorded history, never that the history is absent.
Trait Implementations§
Source§impl Clone for EventIndex
impl Clone for EventIndex
Auto Trait Implementations§
impl Freeze for EventIndex
impl RefUnwindSafe for EventIndex
impl Send for EventIndex
impl Sync for EventIndex
impl Unpin for EventIndex
impl UnsafeUnpin for EventIndex
impl UnwindSafe for EventIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more