Skip to main content

RunOptions

Struct RunOptions 

Source
#[non_exhaustive]
pub struct RunOptions { /* private fields */ }
Expand description

Options controlling run_blocking_with’s pacing and idle behavior.

Implementations§

Source§

impl RunOptions

Source

pub const fn animated(target_fps: u32) -> Self

Options for a continuously-rendering, target_fps-paced loop.

event_driven is false: Flow::Idle only skips present, it never blocks. Use this for apps that drive a retroglyph_ui::Tween/ FrameClock from Frame::delta and need update called every tick regardless of input.

target_fps becomes RunOptions::target_fps verbatim, including 0: passing 0 here builds without panicking, but run_blocking_with panics once it constructs the FrameClock that paces it (see that function’s # Panics section).

Source

pub const fn with_target_fps(self, target_fps: u32) -> Self

Caps the loop at this many App::update calls per second whenever a frame actually runs, using a FrameClock internally to pace them evenly. None (the default) runs uncapped: as fast as update allows for back-to-back Flow::Continue frames, or immediately after whatever woke an event_driven loop from Flow::Idle.

Source

pub const fn target_fps(&self) -> Option<u32>

Returns the configured target_fps cap, if any.

Source

pub const fn event_driven(self, event_driven: bool) -> Self

On Flow::Idle, block on input instead of calling update again immediately.

true (the default) is right for turn-based, event-driven apps that are idle most of the time: an idle frame costs approximately nothing, blocked in the backend’s input read rather than spinning update as fast as the host can manage. false keeps Flow::Idle non-blocking (skip present, keep looping at whatever rate target_fps allows): right for apps that animate from Frame::delta and only return Idle between animation-driven Continue frames, where blocking would freeze the animation until the next stray input event. See RunOptions::animated for that shape.

Source

pub const fn is_event_driven(&self) -> bool

Returns whether Flow::Idle blocks on input rather than looping immediately.

Source

pub const fn with_idle_wake(self, idle_wake: Duration) -> Self

When is_event_driven is true, the longest an idle loop blocks before calling update again anyway, even with no input. None (the default) blocks indefinitely: right for apps with nothing to redraw until input arrives. Some(d) additionally wakes the loop every d, for apps that need a periodic idle redraw (a blinking cursor, a clock) without paying full frame-rate cost. Ignored when is_event_driven is false.

Source

pub const fn idle_wake(&self) -> Option<Duration>

Returns the configured idle_wake interval, if any.

Trait Implementations§

Source§

impl Clone for RunOptions

Source§

fn clone(&self) -> RunOptions

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 Copy for RunOptions

Source§

impl Debug for RunOptions

Source§

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

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

impl Default for RunOptions

Source§

fn default() -> Self

Event-driven, uncapped, blocks indefinitely on Flow::Idle: see run_blocking.

Source§

impl Eq for RunOptions

Source§

impl PartialEq for RunOptions

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RunOptions

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.
Source§

impl<C> WithAlpha for C
where C: Copy,

Source§

fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>

Wraps self with alpha, storing alpha before the color in memory (see AlphaFirst).
Source§

fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>

Wraps self with alpha, storing alpha after the color in memory (see AlphaLast).