pub struct EventRecorder { /* private fields */ }Expand description
Thread-safe session recorder for time-travel debugging. Records events and state checkpoints during a recording session. Only one session can be active at a time.
Implementations§
Source§impl EventRecorder
impl EventRecorder
Sourcepub fn new(max_events: usize) -> Self
pub fn new(max_events: usize) -> Self
Creates a new recorder with the given maximum event capacity.
use victauri_core::EventRecorder;
let recorder = EventRecorder::new(1000);
assert!(!recorder.is_recording());
assert_eq!(recorder.event_count(), 0);Sourcepub fn start(&self, session_id: String) -> Result<()>
pub fn start(&self, session_id: String) -> Result<()>
Starts a new recording session; returns Err if one is already active.
§Errors
Returns VictauriError::RecordingAlreadyActive if a session is already in progress.
§Examples
use victauri_core::EventRecorder;
let recorder = EventRecorder::new(1000);
recorder.start("session-1".to_string()).unwrap();
assert!(recorder.is_recording());Sourcepub fn stop(&self) -> Option<RecordedSession>
pub fn stop(&self) -> Option<RecordedSession>
Stops the active recording and returns the completed session, or None if not recording.
§Examples
use victauri_core::EventRecorder;
let recorder = EventRecorder::new(1000);
recorder.start("session-1".to_string()).unwrap();
let session = recorder.stop().expect("should return session");
assert_eq!(session.id, "session-1");
assert!(!recorder.is_recording());Sourcepub fn is_recording(&self) -> bool
pub fn is_recording(&self) -> bool
Returns true if a recording session is currently active.
Sourcepub fn record_event(&self, event: AppEvent)
pub fn record_event(&self, event: AppEvent)
Appends an event to the active recording, evicting the oldest if at capacity.
Sourcepub fn checkpoint(
&self,
id: String,
label: Option<String>,
state: Value,
) -> Result<()>
pub fn checkpoint( &self, id: String, label: Option<String>, state: Value, ) -> Result<()>
Creates a named state checkpoint at the current event index; returns Err if not recording.
§Errors
Returns VictauriError::NoActiveRecording if no session is in progress.
Sourcepub fn event_count(&self) -> usize
pub fn event_count(&self) -> usize
Returns the number of events recorded so far, or 0 if not recording.
Sourcepub fn checkpoint_count(&self) -> usize
pub fn checkpoint_count(&self) -> usize
Returns the number of checkpoints created so far, or 0 if not recording.
Sourcepub fn events_since(&self, index: usize) -> Vec<RecordedEvent>
pub fn events_since(&self, index: usize) -> Vec<RecordedEvent>
Returns all events with an index >= the given value.
Sourcepub fn events_between(
&self,
from: DateTime<Utc>,
to: DateTime<Utc>,
) -> Vec<RecordedEvent>
pub fn events_between( &self, from: DateTime<Utc>, to: DateTime<Utc>, ) -> Vec<RecordedEvent>
Returns events whose timestamps fall within the given inclusive range.
Sourcepub fn get_checkpoints(&self) -> Vec<StateCheckpoint>
pub fn get_checkpoints(&self) -> Vec<StateCheckpoint>
Returns all checkpoints from the active recording session.
Sourcepub fn events_between_checkpoints(
&self,
from_checkpoint_id: &str,
to_checkpoint_id: &str,
) -> Result<Vec<RecordedEvent>>
pub fn events_between_checkpoints( &self, from_checkpoint_id: &str, to_checkpoint_id: &str, ) -> Result<Vec<RecordedEvent>>
Returns events recorded between two named checkpoints.
§Errors
VictauriError::NoActiveRecordingif no session is active.VictauriError::CheckpointNotFoundif either checkpoint ID does not exist.
Sourcepub fn export(&self) -> Option<RecordedSession>
pub fn export(&self) -> Option<RecordedSession>
Snapshot the current recording as a session WITHOUT stopping it.
Sourcepub fn import(&self, session: RecordedSession)
pub fn import(&self, session: RecordedSession)
Import a previously exported session, replacing any active recording.
Sourcepub fn ipc_replay_sequence(&self) -> Vec<IpcCall>
pub fn ipc_replay_sequence(&self) -> Vec<IpcCall>
Extracts IPC calls in order from the recording for replay.
Trait Implementations§
Source§impl Clone for EventRecorder
impl Clone for EventRecorder
Source§fn clone(&self) -> EventRecorder
fn clone(&self) -> EventRecorder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more