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
impl EventLog
Sourcepub fn from_traces(traces: impl IntoIterator<Item = Trace>) -> Self
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);Sourcepub fn traces(&self) -> &[Trace]
pub fn traces(&self) -> &[Trace]
The traces of this log.
use wasm4pm_compat::eventlog::EventLog;
assert!(EventLog::default().traces().is_empty());Sourcepub fn trace_count(&self) -> usize
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);Sourcepub fn event_count(&self) -> usize
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);Sourcepub fn validate(&self) -> Result<(), EventLogRefusal>
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§
impl Eq for EventLog
Source§impl<'a> IntoIterator for &'a EventLog
impl<'a> IntoIterator for &'a EventLog
Source§fn into_iter(self) -> Self::IntoIter
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"]);