pub struct InputRecorder<B> { /* private fields */ }Expand description
Wraps a backend and records every event it sees.
Works over a Backend, or any subset of
Output/Input/Cursor: taps Input::poll_event to capture, while delegating
everything else unchanged.
Recording starts immediately on construction; use handle (or the
convenience start/pause/stop/
save methods on this type, which forward to it) to control capture and save
it to a .rgrec file.
§Examples
use retroglyph_core::backend::{Headless, Input};
use retroglyph_core::event::{Event, KeyCode, KeyEvent, KeyModifiers};
use retroglyph_recorder::InputRecorder;
let mut recorder = InputRecorder::new(Headless::new(10, 3));
recorder.push_event(Event::Key(KeyEvent::new(KeyCode::Char('a'), KeyModifiers::NONE)));
let event = recorder.poll_event(std::time::Duration::ZERO);
assert!(event.is_some());
let recording = recorder.stop();
assert_eq!(recording.len(), 1);Implementations§
Source§impl<B: Output> InputRecorder<B>
impl<B: Output> InputRecorder<B>
Sourcepub fn new(inner: B) -> Self
pub fn new(inner: B) -> Self
Wraps inner, sizing the recording to inner’s current Output::size.
Source§impl<B> InputRecorder<B>
impl<B> InputRecorder<B>
Sourcepub fn handle(&self) -> RecorderHandle
pub fn handle(&self) -> RecorderHandle
A cloneable RecorderHandle onto this recorder’s shared state, for reaching in from
another call stack (see RecorderHandle’s own docs).
Sourcepub fn start(&self)
pub fn start(&self)
RecorderHandle::start on this recorder’s own handle.
Sourcepub fn pause(&self)
pub fn pause(&self)
RecorderHandle::pause on this recorder’s own handle.
Sourcepub fn snapshot(&self) -> InputRecording
pub fn snapshot(&self) -> InputRecording
RecorderHandle::snapshot on this recorder’s own handle.
Sourcepub fn stop(&self) -> InputRecording
pub fn stop(&self) -> InputRecording
RecorderHandle::stop on this recorder’s own handle.
Sourcepub fn save(&self, path: impl AsRef<Path>) -> Result<()>
pub fn save(&self, path: impl AsRef<Path>) -> Result<()>
RecorderHandle::save on this recorder’s own handle.
§Errors
Returns an error if path cannot be created or written to.
Trait Implementations§
Source§impl<B: Cursor> Cursor for InputRecorder<B>
impl<B: Cursor> Cursor for InputRecorder<B>
Source§fn set_cursor_visible(&mut self, visible: bool)
fn set_cursor_visible(&mut self, visible: bool)
Source§fn set_cursor_position(&mut self, position: Pos)
fn set_cursor_position(&mut self, position: Pos)
Source§fn set_cursor_style(&mut self, style: CursorStyle)
fn set_cursor_style(&mut self, style: CursorStyle)
Source§impl<B: Input> Input for InputRecorder<B>
impl<B: Input> Input for InputRecorder<B>
Source§impl<B: Output> Output for InputRecorder<B>
impl<B: Output> Output for InputRecorder<B>
Source§fn draw<'a, I>(&mut self, content: I) -> Result<(), Self::Error>
fn draw<'a, I>(&mut self, content: I) -> Result<(), Self::Error>
Source§fn draw_layers<'a, I>(&mut self, content: I) -> Result<(), Self::Error>
fn draw_layers<'a, I>(&mut self, content: I) -> Result<(), Self::Error>
Source§fn compositing(&self) -> Compositing
fn compositing(&self) -> Compositing
draw_layers. Read moreAuto Trait Implementations§
impl<B> Freeze for InputRecorder<B>where
B: Freeze,
impl<B> RefUnwindSafe for InputRecorder<B>where
B: RefUnwindSafe,
impl<B> Send for InputRecorder<B>where
B: Send,
impl<B> Sync for InputRecorder<B>where
B: Sync,
impl<B> Unpin for InputRecorder<B>where
B: Unpin,
impl<B> UnsafeUnpin for InputRecorder<B>where
B: UnsafeUnpin,
impl<B> UnwindSafe for InputRecorder<B>where
B: UnwindSafe,
Blanket Implementations§
impl<T> Backend for T
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.