#[non_exhaustive]pub struct RunOptions { /* private fields */ }Expand description
Options controlling run_blocking_with’s pacing and idle behavior.
Implementations§
Source§impl RunOptions
impl RunOptions
Sourcepub const fn animated(target_fps: u32) -> Self
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).
Sourcepub const fn with_target_fps(self, target_fps: u32) -> Self
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.
Sourcepub const fn target_fps(&self) -> Option<u32>
pub const fn target_fps(&self) -> Option<u32>
Returns the configured target_fps cap, if any.
Sourcepub const fn event_driven(self, event_driven: bool) -> Self
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.
Sourcepub const fn is_event_driven(&self) -> bool
pub const fn is_event_driven(&self) -> bool
Returns whether Flow::Idle blocks on input rather than looping immediately.
Sourcepub const fn with_idle_wake(self, idle_wake: Duration) -> Self
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.
Trait Implementations§
Source§impl Clone for RunOptions
impl Clone for RunOptions
Source§fn clone(&self) -> RunOptions
fn clone(&self) -> RunOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for RunOptions
Source§impl Debug for RunOptions
impl Debug for RunOptions
Source§impl Default for RunOptions
impl Default for RunOptions
Source§fn default() -> Self
fn default() -> Self
Event-driven, uncapped, blocks indefinitely on Flow::Idle: see run_blocking.