pub struct EventRecorder { /* private fields */ }Expand description
Records events from a live event stream with start/stop/pause control.
This is a higher-level wrapper around MacroRecorder designed for
integration with the Program event loop.
§Usage
let mut recorder = EventRecorder::new("my_session");
recorder.start();
// In event loop:
for event in events {
recorder.record(&event); // No-op if not recording
// ... process event normally ...
}
recorder.pause();
// ... events here are not recorded ...
recorder.resume();
let macro_recording = recorder.finish();Implementations§
Source§impl EventRecorder
impl EventRecorder
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Create a new recorder with the given name.
Starts in RecordingState::Idle. Call start
to begin recording.
Sourcepub fn with_terminal_size(self, width: u16, height: u16) -> Self
pub fn with_terminal_size(self, width: u16, height: u16) -> Self
Set the terminal size metadata.
Sourcepub fn state(&self) -> RecordingState
pub fn state(&self) -> RecordingState
Get the current recording state.
Sourcepub fn is_recording(&self) -> bool
pub fn is_recording(&self) -> bool
Check if actively recording (not idle or paused).
Sourcepub fn pause(&mut self)
pub fn pause(&mut self)
Pause recording. Events received while paused are ignored.
No-op if not recording.
Sourcepub fn record(&mut self, event: &Event) -> bool
pub fn record(&mut self, event: &Event) -> bool
Record an event. Only records if state is RecordingState::Recording.
Returns true if the event was recorded.
Sourcepub fn record_with_delay(&mut self, event: &Event, delay: Duration) -> bool
pub fn record_with_delay(&mut self, event: &Event, delay: Duration) -> bool
Record an event with an explicit delay override.
Returns true if the event was recorded.
Sourcepub fn event_count(&self) -> usize
pub fn event_count(&self) -> usize
Get the number of events recorded so far.
Sourcepub fn total_paused(&self) -> Duration
pub fn total_paused(&self) -> Duration
Get the total time spent paused.
Sourcepub fn finish(self) -> InputMacro
pub fn finish(self) -> InputMacro
Stop recording and produce the final InputMacro.
Consumes the recorder.