Skip to main content

EventLog

Struct EventLog 

Source
pub struct EventLog { /* private fields */ }
Expand description

A collection of Traces — the classical case-centric event log.

An EventLog is the substrate of discovery and conformance. This crate only represents and structurally validates it; the actual mining graduates to wasm4pm.

Structure-only: EventLog::validate runs each trace’s structural checks but performs no analysis.

Implementations§

Source§

impl EventLog

Source

pub fn from_traces(traces: impl IntoIterator<Item = Trace>) -> Self

Construct a log from an iterator of traces.

use wasm4pm_compat::eventlog::{Event, Trace, EventLog};
let log = EventLog::from_traces([Trace::new("c", [Event::new("a")])]);
assert_eq!(log.trace_count(), 1);
Source

pub fn traces(&self) -> &[Trace]

The traces of this log.

use wasm4pm_compat::eventlog::EventLog;
assert!(EventLog::default().traces().is_empty());
Source

pub fn trace_count(&self) -> usize

The number of traces in this log.

use wasm4pm_compat::eventlog::{Event, Trace, EventLog};
let log = EventLog::from_traces([Trace::new("c", [Event::new("a")])]);
assert_eq!(log.trace_count(), 1);
Source

pub fn event_count(&self) -> usize

The total number of events across all traces.

use wasm4pm_compat::eventlog::{Event, Trace, EventLog};
let log = EventLog::from_traces([
    Trace::new("c1", [Event::new("a"), Event::new("b")]),
    Trace::new("c2", [Event::new("a")]),
]);
assert_eq!(log.event_count(), 3);
Source

pub fn validate(&self) -> Result<(), EventLogRefusal>

Validate every trace structurally, returning the first refusal.

This is a shape check across the whole log; it does not discover or score anything. For mining, graduate to wasm4pm.

use wasm4pm_compat::eventlog::{Trace, EventLog, EventLogRefusal};
let bad = EventLog::from_traces([Trace::from_events([])]);
assert_eq!(bad.validate(), Err(EventLogRefusal::EmptyTrace));

Trait Implementations§

Source§

impl Clone for EventLog

Source§

fn clone(&self) -> EventLog

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 EventLog

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for EventLog

Source§

fn default() -> EventLog

Returns the “default value” for a type. Read more
Source§

impl Eq for EventLog

Source§

impl<'a> IntoIterator for &'a EventLog

Source§

fn into_iter(self) -> Self::IntoIter

Iterate over the Traces of this log.

This makes EventLog idiomatic to use in for loops and iterator chains without a separate .traces() call:

use wasm4pm_compat::eventlog::{Event, Trace, EventLog};
let log = EventLog::from_traces([
    Trace::new("c1", [Event::new("a")]),
    Trace::new("c2", [Event::new("b")]),
]);
let cases: Vec<&str> = (&log).into_iter().map(|t| t.case_id()).collect();
assert_eq!(cases, ["c1", "c2"]);
Source§

type Item = &'a Trace

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, Trace>

Which kind of iterator are we turning this into?
Source§

impl IntoIterator for EventLog

Source§

fn into_iter(self) -> Self::IntoIter

Consume the log and iterate over its Traces by value.

use wasm4pm_compat::eventlog::{Event, Trace, EventLog};
let log = EventLog::from_traces([Trace::new("c", [Event::new("a")])]);
let v: Vec<Trace> = log.into_iter().collect();
assert_eq!(v.len(), 1);
Source§

type Item = Trace

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<Trace>

Which kind of iterator are we turning this into?
Source§

impl PartialEq for EventLog

Source§

fn eq(&self, other: &EventLog) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for EventLog

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> EvidenceKind for T

Source§

default fn kind_label(&self) -> &'static str

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.