Skip to main content

Module reader

Module reader 

Source
Expand description

Reading a trace bundle (issue #87).

The reader assumes nothing finished cleanly. A run that was killed leaves a bundle with no manifest and a half-written last line; that bundle still holds the evidence someone is looking for, so it is repaired on open rather than rejected. This mirrors js/src/traces/reader.js and python/src/browser_commander/traces/reader.py, down to the messages, so a bundle reads the same whichever language opens it.

§Example

use browser_commander::traces::{diff_control_state, read_trace};

let trace = read_trace("./traces/run")?;
println!("{} events", trace.events.len());

let before = trace.state(1)?;
let after = trace.state(2)?;
for change in diff_control_state(before.as_ref(), after.as_ref()) {
    println!("{} {}", change.change.as_str(), change.path.unwrap_or_default());
}

Structs§

ControlChange
One control that differs between two checkpoints.
ParsedNdjson
What an NDJSON file held, and whether it ended mid-line.
Trace
An opened trace bundle.
TraceCheckpoint
One named moment, as the timeline describes it.

Enums§

ControlChangeKind
Which way a control went between two checkpoints.
TraceError
Everything that can stop a bundle from being read.

Functions§

diff_control_state
Diff two checkpoints’ control state.
parse_ndjson
Parse an NDJSON body, keeping everything before the first unreadable line.
read_trace
Open a trace bundle.