Skip to main content

Runtime

Struct Runtime 

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

Coordinates simulation-latched input, a fixed-rate simulation clock, and presentation pacing.

Implementations§

Source§

impl Runtime

Source

pub fn new(config: RuntimeConfig, started_at: Instant) -> Self

Starts a runtime clock at started_at with no accumulated simulation debt.

Source

pub fn record_presented(&mut self, presented_at: Instant)

Records one presented frame with the display time the backend reported for it.

Drain the graphics surface’s presentation feedback into this method (or Self::record_untimed_presented) every frame. Once the recorded timestamps yield a cadence estimate, Self::begin_frame advances simulation time by whole display intervals instead of wall-clock gaps.

Source

pub fn record_untimed_presented(&mut self)

Records one frame whose presentation completed without a reported display time, such as while the window is off screen.

Source

pub fn pacing_report(&self) -> PacingReport

Summarizes the presentation pacing recorded so far.

Source

pub fn handle_input(&mut self, event: InputEvent)

Adds one ordered native input transition to the current snapshot.

Source

pub fn handle_window_event(&mut self, event: WindowEvent)

Applies the input and rendering-lifecycle parts of one platform window event.

Redraw, metrics, and close policy remain with the application. Lower-level input, suspend, and resume methods remain available when an application uses a different coordination shape.

Source

pub const fn input(&self) -> &InputSnapshot

Returns held state and transitions accumulated since the last simulation-bearing frame.

Source

pub fn begin_frame(&mut self, now: Instant) -> RuntimeFrame<'_>

Begins a scoped frame with fixed simulation work, input, and render interpolation.

While recorded presentation feedback yields a fresh cadence estimate, the frame delta is a whole number of display intervals; call this once per frame that will be presented, since every paced call advances at least one interval. Without feedback, or when it goes stale, the delta observably falls back to the wall-clock gap since the previous frame — see RuntimeFrame::schedule.

Dropping a frame with fixed updates consumes transient input, including on early return. A frame with no fixed update retains it for the next simulation-bearing frame.

Source

pub fn suspend(&mut self)

Pauses frame timing and releases every held input control.

The fractional fixed-step accumulator is preserved so rendering can resume without a small interpolation jump. Calls to Self::begin_frame while suspended schedule no updates.

Source

pub fn resume(&mut self, now: Instant)

Resumes frame timing from now without treating the suspended interval as elapsed game time.

Source

pub const fn suspended(&self) -> bool

Returns whether frame timing is currently suspended.

Trait Implementations§

Source§

impl Debug for Runtime

Source§

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

Formats the value using the given formatter. 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, 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.