Skip to main content

DiffPool

Struct DiffPool 

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

Pre-allocated 1.1MB ring buffer of WavDiff entries.

Never grows. When full, oldest entries are overwritten. At 120Hz with ~100 diffs/frame, this holds ~640 frames (~5.3 seconds) of history — well beyond the 120-frame rollback window.

Implementations§

Source§

impl DiffPool

Source

pub fn new() -> Self

Create a new pre-allocated DiffPool. All slots zeroed. Single heap allocation at boot — never grows.

Source

pub fn push(&mut self, diff: WavDiff) -> u32

Append a diff to the ring buffer. Returns the absolute index. O(1), no allocation.

Source

pub fn get(&self, index: u32) -> Option<&WavDiff>

Get a diff by absolute index. Returns None if index is out of range.

Source

pub fn head(&self) -> usize

Current write head position.

Source

pub fn count(&self) -> usize

Number of valid entries in the pool.

Source

pub fn frame_diffs(&self, start: u32, count: u16) -> FrameDiffIter<'_>

Iterate diffs for a frame given start index and count. Handles ring buffer wrap-around.

Source

pub fn frame_diffs_reverse( &self, start: u32, count: u16, ) -> FrameDiffReverseIter<'_>

Iterate diffs for a frame in reverse order (for rewind). Traverses from start + count - 1 back to start.

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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.