Struct TickBatch

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

An allocation-free snapshot of a frame budget and its scheduled tick IDs.

Created by FixedClock::advance_batch, session::GameSession::advance_batch or session::GameSession::step_paused_batch. Scheduling already advanced the clock by the whole budget. Iterating, skipping, copying or dropping this value never advances or rolls back that clock and does not record actual execution. Track executed updates in your runner; an iterator yield alone is not an update.

A snapshot keeps its original IDs even after the clock advances or resets. Discard pending batches when resetting your simulation, since reset reuses IDs. See Self::ticks for an example of abandoning a batch early.

Implementations§

Source§

impl TickBatch

Source

pub fn frame(self) -> FrameStep

The unchanged timing budget, including zero-work and paused-step alpha.

use ferravex_core::FixedClock;
let batch = FixedClock::new(64.0, 2).advance_batch(3.5 / 64.0);
assert_eq!(batch.frame().steps, 2);
assert_eq!(batch.frame().alpha, 0.5);
assert_eq!(batch.frame().dropped_seconds, 1.0 / 64.0);
Source

pub fn ticks( self, ) -> impl ExactSizeIterator<Item = TickContext> + DoubleEndedIterator + FusedIterator

Iterate scheduled contexts without allocation or borrowing the clock.

Each ID is tick_before.wrapping_add(batch_index + 1). Discarded catch-up time consumes no IDs. Empty budgets yield nothing. Every call produces the same contexts, so executing a batch twice would repeat work with the same IDs. Reverse/skip iteration preserves indices from the original forward order. nth/nth_back skip in constant time, even for a maximum-sized budget.

use ferravex_core::FixedClock;
let mut clock = FixedClock::new(64.0, 8);
let batch = clock.advance_batch(3.0 / 64.0);
let mut executed = 0;
for context in batch.ticks().take(1) {
    assert_eq!(context.tick, 1);
    assert_eq!(context.batch_index, 0);
    assert_eq!(context.dt, 1.0 / 64.0);
    executed += 1; // Invoke the simulation here, then stop this batch.
}
assert_eq!(executed, 1);
assert_eq!(clock.tick(), 3); // Includes the two unexecuted scheduled IDs.
assert_eq!(clock.advance_batch(1.0 / 64.0).ticks().next().unwrap().tick, 4);

Trait Implementations§

Source§

impl Clone for TickBatch

Source§

fn clone(&self) -> TickBatch

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TickBatch

Source§

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

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

impl Copy for TickBatch

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 = 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.