Skip to main content

MoviePlayer

Struct MoviePlayer 

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

Replays a recorded Movie’s input log against a System already positioned at its start point (via Movie::seek_to_start).

Owns the Movie (rather than borrowing it) specifically so a long-lived host — the frontend’s per-frame drive, holding a player across many real frames — can store one without a self-referential lifetime; Self::movie hands it back if the caller needs it afterward (e.g. to re-verify the ROM hash, or to inspect how many frames were recorded).

Implementations§

Source§

impl MoviePlayer

Source

pub const fn new(movie: Movie) -> Self

A player starting at the first recorded frame.

Source

pub const fn movie(&self) -> &Movie

The movie being played back.

Source

pub fn next_frame(&mut self) -> Option<FrameInput>

Advance the playback cursor and return the next recorded frame’s input, or None if the movie is exhausted (the caller should stop).

Deliberately does NOT touch a System/Bus itself (unlike an earlier design) — a host that drives input through its own abstraction (e.g. rustysnes-frontend’s EmuCore:: set_pad, which EmuCore::run_frame re-applies from its OWN retained pad state every call) needs to feed the returned FrameInput through THAT abstraction, not have this reach around it and write Bus::set_joypad directly — the two would race for who “wins” depending on call order. A caller working with a bare System directly (as the determinism-replay test does) can just call sys.bus.set_joypad(0, f.p1) / set_joypad(1, f.p2) itself with the returned value.

Source

pub const fn frames_remaining(&self) -> usize

Frames not yet applied.

Source

pub const fn is_finished(&self) -> bool

Whether every recorded frame has been applied.

Trait Implementations§

Source§

impl Debug for MoviePlayer

Source§

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

Formats the value using the given formatter. Read more

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, 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> Same for T

Source§

type Output = T

Should always be Self
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.