Skip to main content

RewindRing

Struct RewindRing 

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

Rewind ring buffer.

Configure once via Self::new (or Self::default); call Self::push after each emulated frame; call Self::pop_back to step backwards in time during rewind playback.

Implementations§

Source§

impl RewindRing

Source

pub fn new(max_bytes: usize, keyframe_period: u32) -> Self

New ring with max_bytes of in-memory budget and a keyframe every keyframe_period captures.

keyframe_period of 0 is treated as 1 (every entry is a keyframe).

Source

pub fn len(&self) -> usize

Number of buffered entries (each one is a frame).

Source

pub fn is_empty(&self) -> bool

true if no frames are buffered.

Source

pub const fn bytes_used(&self) -> usize

Approximate memory footprint in bytes.

Source

pub fn clear(&mut self)

Drop every entry.

Source

pub fn push(&mut self, frame: u64, snapshot: &[u8])

Capture one frame’s worth of state.

frame is informational; pass the emulator’s frame counter so debug output can label entries.

Source

pub fn pop_back(&mut self) -> Option<Result<Vec<u8>, RewindError>>

Pop the most recent entry and return its decoded snapshot bytes.

Returns None when the ring is empty. Walking back across a keyframe boundary is allowed; once the keyframe itself is consumed, the next pop reads its predecessor (which must itself be a keyframe — by construction, since deltas refer forward to a keyframe).

§Errors

Returns RewindError when an entry can’t be reconstructed (corrupt LZ4 payload, etc.).

Source

pub fn back_frame(&self) -> Option<u64>

Borrow the most recent entry’s frame number, if any.

Trait Implementations§

Source§

impl Debug for RewindRing

Source§

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

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

impl Default for RewindRing

Source§

fn default() -> Self

Returns the “default value” for a type. 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.