Skip to main content

EventRecorder

Struct EventRecorder 

Source
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

Source

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.

Source

pub fn with_terminal_size(self, width: u16, height: u16) -> Self

Set the terminal size metadata.

Source

pub fn state(&self) -> RecordingState

Get the current recording state.

Source

pub fn is_recording(&self) -> bool

Check if actively recording (not idle or paused).

Source

pub fn start(&mut self)

Start recording. No-op if already recording.

Source

pub fn pause(&mut self)

Pause recording. Events received while paused are ignored.

No-op if not recording.

Source

pub fn resume(&mut self)

Resume recording after a pause.

No-op if not paused.

Source

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.

Source

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.

Source

pub fn event_count(&self) -> usize

Get the number of events recorded so far.

Source

pub fn total_paused(&self) -> Duration

Get the total time spent paused.

Source

pub fn finish(self) -> InputMacro

Stop recording and produce the final InputMacro.

Consumes the recorder.

Source

pub fn discard(self) -> usize

Stop recording and discard all events.

Returns the number of events that were discarded.

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more