Skip to main content

DoubleBufferedSnapshot

Struct DoubleBufferedSnapshot 

Source
pub struct DoubleBufferedSnapshot<S> { /* private fields */ }
Expand description

Three-slot double-buffered snapshot store decoupling fixed-step simulation commits from zero-allocation high-refresh render interpolation.

Implementations§

Source§

impl<S> DoubleBufferedSnapshot<S>
where S: Clone,

Construction, zero-allocation in-place capture, discontinuity handling, and interpolation sampling for DoubleBufferedSnapshot.

Source

pub fn new(initial: S) -> Self

Initializes a three-slot double-buffered snapshot store with initial across all persistent slots.

§Arguments
  • S - Initial simulation state snapshot.
§Returns
  • Self - Initialized three-slot snapshot buffer.
Source

pub fn commit(&mut self, next: S)

Commits a continuous fixed-step snapshot, promoting the prior curr_state into prev_state.

§Arguments
  • &Self - Mutable snapshot buffer.
  • S - New immutable simulation state snapshot.
Source

pub fn capture_into<F>(&mut self, capture_fn: F)
where F: FnOnce(&mut S),

Rotates curr_state into prev_state and populates the recycled curr_state slot in place via capture_fn with zero heap allocations.

§Arguments
  • &Self - Mutable snapshot buffer.
  • F - Closure overwriting the recycled &mut S slot in place.
Source

pub fn capture_discontinuous_into<F>(&mut self, capture_fn: F)
where F: FnOnce(&mut S),

Captures a discontinuous snapshot in place via capture_fn, preventing interpolation across the boundary without reallocating backing vectors.

§Arguments
  • &Self - Mutable snapshot buffer.
  • F - Closure overwriting curr_state in place.
Source

pub fn commit_discontinuous(&mut self, next: S)

Commits a discontinuous snapshot (teleport, scene reset, or hard camera cut), preventing interpolation across the boundary.

§Arguments
  • &Self - Mutable snapshot buffer.
  • S - New immutable simulation state snapshot.
Source

pub fn sample_into(&self, alpha: f32, out: &mut S)

Samples the render-time state at normalized alpha in [0.0, 1.0] directly into pre-allocated out with zero heap allocations.

§Arguments
  • &Self - Snapshot buffer reference.
  • f32 - Normalized interpolation factor between previous and current fixed steps.
  • &mut S - Persistent destination snapshot overwritten in place.
Source

pub fn sample_cached(&mut self, alpha: f32) -> &S

Samples the render-time state at alpha into the internal third persistent interp_scratch slot and borrows it with zero allocations.

§Arguments
  • &Self - Mutable snapshot buffer.
  • f32 - Normalized interpolation factor in [0.0, 1.0].
§Returns
  • &S - Borrowed interpolated snapshot stored in the persistent scratch slot.
Source

pub fn sample(&self, alpha: f32) -> S

Samples the render-time state at normalized alpha in [0.0, 1.0].

§Arguments
  • &Self - Snapshot buffer reference.
  • f32 - Normalized interpolation factor between previous and current fixed steps.
§Returns
  • S - Interpolated snapshot or exact curr_state on discontinuities.
Source§

impl<S> DoubleBufferedSnapshot<S>

Source

pub fn get_prev_state(&self) -> &S

Source

pub fn get_mut_prev_state(&mut self) -> &mut S

Source

pub fn set_prev_state(&mut self, val: S) -> &mut Self

Source

pub fn get_curr_state(&self) -> &S

Source

pub fn get_mut_curr_state(&mut self) -> &mut S

Source

pub fn set_curr_state(&mut self, val: S) -> &mut Self

Source

pub fn get_tick(&self) -> u64

Source

pub fn get_mut_tick(&mut self) -> &mut u64

Source

pub fn set_tick(&mut self, val: u64) -> &mut Self

Source

pub fn get_discontinuity_tick(&self) -> u64

Source

pub fn get_mut_discontinuity_tick(&mut self) -> &mut u64

Source

pub fn set_discontinuity_tick(&mut self, val: u64) -> &mut Self

Source

pub fn get_has_prev(&self) -> bool

Source

pub fn get_mut_has_prev(&mut self) -> &mut bool

Source

pub fn set_has_prev(&mut self, val: bool) -> &mut Self

Trait Implementations§

Source§

impl<S: Clone> Clone for DoubleBufferedSnapshot<S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Debug> Debug for DoubleBufferedSnapshot<S>

Source§

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

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

impl<S: PartialEq> PartialEq for DoubleBufferedSnapshot<S>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<S: PartialEq> StructuralPartialEq for DoubleBufferedSnapshot<S>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.