Skip to main content

TraceReader

Struct TraceReader 

Source
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>

Source

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.

Source

pub fn context(&self) -> &ContextOptions

The context-options metadata from the trace’s first event.

Source

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.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<R> Freeze for TraceReader<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for TraceReader<R>
where R: RefUnwindSafe,

§

impl<R> Send for TraceReader<R>
where R: Send,

§

impl<R> Sync for TraceReader<R>
where R: Sync,

§

impl<R> Unpin for TraceReader<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for TraceReader<R>
where R: UnsafeUnpin,

§

impl<R> UnwindSafe for TraceReader<R>
where R: UnwindSafe,

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> 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, 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.