Skip to main content

EventIndex

Struct EventIndex 

Source
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

Source

pub fn new(scope: AnalyticsScope) -> Self

An empty index for a scope.

Source

pub fn scope(&self) -> &AnalyticsScope

The scope every contribution in this index was classified against.

Source

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.

Source

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.

Source

pub fn events(&self) -> impl Iterator<Item = &AnalyticsEvent> + '_

The contributed events, in first-seen order.

Source

pub fn of_class( &self, class: EventClass, ) -> impl Iterator<Item = &AnalyticsEvent> + '_

The contributed events of one class, in first-seen order.

Source

pub fn count_of(&self, class: EventClass) -> usize

How many events of one class contributed.

Source

pub fn len(&self) -> usize

How many contributions the index holds.

Source

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.

Source

pub fn duplicates(&self) -> usize

How many repeated classifications the index rejected (C-002).

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for EventIndex

Source§

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

Formats the value using the given formatter. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.