pub struct TraceReader<R: Read + Seek> { /* private fields */ }Expand description
Streaming reader over a Playwright trace zip.
Opens the archive and parses the first event (context-options)
eagerly so the trace’s metadata is available without consuming the
rest of the stream. Subsequent calls to
raw_events, events, or
actions iterate the remaining events lazily;
each call extracts a fresh JSONL stream from the archive, so the
reader can be iterated multiple times.
Implementations§
Source§impl<R: Read + Seek> TraceReader<R>
impl<R: Read + Seek> TraceReader<R>
Sourcepub fn open(reader: R) -> Result<Self>
pub fn open(reader: R) -> Result<Self>
Open a trace from any Read + Seek source. For the typical
file-on-disk case prefer crate::open.
Sourcepub fn context(&self) -> &ContextOptions
pub fn context(&self) -> &ContextOptions
The context-options metadata from the trace’s first event.
Sourcepub fn raw_events(&mut self) -> Result<impl Iterator<Item = Result<RawEvent>>>
pub fn raw_events(&mut self) -> Result<impl Iterator<Item = Result<RawEvent>>>
Lossless stream of every JSONL event in trace.trace. Yields a
RawEvent per line; callers can dispatch on
RawEvent::kind to handle event types
the typed enum doesn’t model.
The first event (context-options) is included in the
stream; if you only need it, context is
already cached.
Sourcepub fn events(&mut self) -> Result<impl Iterator<Item = Result<TraceEvent>>>
pub fn events(&mut self) -> Result<impl Iterator<Item = Result<TraceEvent>>>
Typed stream of events. Wraps raw_events
and routes each RawEvent through
RawEvent::into_typed. Unknown
or unmodelled kinds surface as TraceEvent::Unknown.
Sourcepub fn actions(&mut self) -> Result<impl Iterator<Item = Result<Action>>>
pub fn actions(&mut self) -> Result<impl Iterator<Item = Result<Action>>>
Reassembled action stream — before + optional input + zero-
or-more log + after events sharing a call_id are merged
into one Action.
Actions are yielded in after-arrival order, not strictly
in start_time order — concurrent calls can interleave.
Callers wanting chronological order should collect into a
Vec and sort by Action::start_time.
Truncated actions (no matching after event, e.g. a trace cut
short by a crash) are emitted at end-of-stream with
end_time = None rather than discarded.
Sourcepub fn network(&mut self) -> Result<impl Iterator<Item = Result<NetworkEntry>>>
pub fn network(&mut self) -> Result<impl Iterator<Item = Result<NetworkEntry>>>
Streaming iterator over NetworkEntry records from
trace.network. Yields zero items when the trace recorded no
requests (the entry is present but empty).
HAR fields not modelled on NetworkEntry are preserved on
NetworkEntry::raw_snapshot.