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
impl RewindRing
Sourcepub fn new(max_bytes: usize, keyframe_period: u32) -> Self
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).
Sourcepub const fn bytes_used(&self) -> usize
pub const fn bytes_used(&self) -> usize
Approximate memory footprint in bytes.
Sourcepub fn push(&mut self, frame: u64, snapshot: &[u8])
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.
Sourcepub fn pop_back(&mut self) -> Option<Result<Vec<u8>, RewindError>>
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.).
Sourcepub fn back_frame(&self) -> Option<u64>
pub fn back_frame(&self) -> Option<u64>
Borrow the most recent entry’s frame number, if any.