pub struct SessionPlayer { /* private fields */ }Expand description
Plays back recorded sessions.
SessionPlayer reads JSONL records, extracts timing information,
and replays events with configurable speed and output modes.
§Example
use ralph_core::{SessionPlayer, PlayerConfig};
use std::io::Cursor;
let jsonl = r#"{"ts":1000,"event":"ux.terminal.write","data":{"bytes":"SGVsbG8=","stdout":true,"offset_ms":0}}
{"ts":1100,"event":"ux.terminal.write","data":{"bytes":"V29ybGQ=","stdout":true,"offset_ms":100}}"#;
let reader = Cursor::new(jsonl);
let player = SessionPlayer::from_reader(reader).unwrap();
assert_eq!(player.record_count(), 2);Implementations§
Source§impl SessionPlayer
impl SessionPlayer
Sourcepub fn from_reader<R: BufRead>(reader: R) -> Result<Self>
pub fn from_reader<R: BufRead>(reader: R) -> Result<Self>
Creates a player from a JSONL reader.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Creates a player from raw JSONL bytes.
Sourcepub fn with_config(self, config: PlayerConfig) -> Self
pub fn with_config(self, config: PlayerConfig) -> Self
Sets the playback configuration.
Sourcepub fn record_count(&self) -> usize
pub fn record_count(&self) -> usize
Returns the number of records.
Sourcepub fn records(&self) -> &[TimestampedRecord]
pub fn records(&self) -> &[TimestampedRecord]
Returns all records.
Sourcepub fn filter_by_event(&self, event_prefix: &str) -> Vec<&TimestampedRecord>
pub fn filter_by_event(&self, event_prefix: &str) -> Vec<&TimestampedRecord>
Returns records filtered by event type.
Sourcepub fn terminal_writes(&self) -> Vec<&TimestampedRecord>
pub fn terminal_writes(&self) -> Vec<&TimestampedRecord>
Returns only UX terminal write events.
Sourcepub fn metadata_events(&self) -> Vec<&TimestampedRecord>
pub fn metadata_events(&self) -> Vec<&TimestampedRecord>
Returns only metadata events.
Sourcepub fn bus_events(&self) -> Vec<&TimestampedRecord>
pub fn bus_events(&self) -> Vec<&TimestampedRecord>
Returns only bus events.
Sourcepub fn replay_terminal<W: Write>(&mut self, writer: &mut W) -> Result<()>
pub fn replay_terminal<W: Write>(&mut self, writer: &mut W) -> Result<()>
Replays all UX terminal events to the given writer.
This is a synchronous replay that respects timing delays adjusted by the speed multiplier. In step mode, it waits for Enter after each event.
Sourcepub fn collect_terminal_output(&self) -> Result<String>
pub fn collect_terminal_output(&self) -> Result<String>
Collects all terminal output as a single string (for snapshot testing).
Sourcepub fn collect_text_output(&self) -> Result<String>
pub fn collect_text_output(&self) -> Result<String>
Collects terminal output with ANSI codes stripped (for text snapshot testing).
Sourcepub fn collect_ansi_escaped(&self) -> Result<String>
pub fn collect_ansi_escaped(&self) -> Result<String>
Collects terminal output with ANSI codes escaped (for ANSI snapshot testing).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SessionPlayer
impl RefUnwindSafe for SessionPlayer
impl Send for SessionPlayer
impl Sync for SessionPlayer
impl Unpin for SessionPlayer
impl UnwindSafe for SessionPlayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Erasable for T
impl<T> Erasable for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more