Skip to main content

InputRecording

Struct InputRecording 

Source
pub struct InputRecording { /* private fields */ }
Expand description

A recorded input session: the backend size it was captured against, plus a timed sequence of events.

Each event’s Duration is the delay since the previous recorded event (or since the start of the recording, for the first one), not an absolute timestamp measured from session start – see push. That’s the shape TestHarness::replay needs to reproduce recorded pacing faithfully instead of collapsing every gap to zero.

no_std + alloc compatible, gated on the testing feature like the rest of this module. Serialize/Deserialize are additionally gated on serde: driving a recording back through a live App within the same process (what this type and TestHarness::replay do) needs no serialization at all; turning a recording into bytes on disk (the .rgrec format) is retroglyph-recorder’s job, built on top of these derives.

Implementations§

Source§

impl InputRecording

Source

pub const fn new(width: u16, height: u16) -> Self

Creates an empty recording for a width x height backend.

Source

pub const fn width(&self) -> u16

The backend width this recording was captured against.

Source

pub const fn height(&self) -> u16

The backend height this recording was captured against.

Source

pub fn push(&mut self, delay: Duration, event: Event)

Appends event, delay after the previously appended event (or after the start of the recording, for the first).

Source

pub fn events(&self) -> impl ExactSizeIterator<Item = &(Duration, Event)>

Iterates the recorded (delay, event) pairs, in the order they were pushed.

Source

pub const fn len(&self) -> usize

The number of recorded events.

Source

pub const fn is_empty(&self) -> bool

Returns true if no events have been recorded.

Trait Implementations§

Source§

impl Clone for InputRecording

Source§

fn clone(&self) -> InputRecording

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InputRecording

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for InputRecording

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for InputRecording

Source§

fn eq(&self, other: &InputRecording) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for InputRecording

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for InputRecording

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.