pub struct CosmeticLoopRate(/* private fields */);Expand description
The CosmeticLoop tick-rate cap (Hz) — an app-tunable pacing token
consumed by the frame gate’s pacing: a
purely cosmetic, indefinitely-looping animation (a shimmer/pulse with no
user-visible endpoint) is capped to this rate rather than repainting
every display frame. Uncapped (0/None) is not an allowed value —
a cosmetic loop always paces to some ceiling, so this type clamps any
constructed value up to CosmeticLoopRate::FLOOR_HZ (10Hz), a sane
floor below which a “cosmetic” loop reads as visibly stuttering rather
than paced.
This token only declares the cap; nothing in frust-theme reads a
clock or paces a loop — the frame-gate consumer is what actually honors it.
Implementations§
Source§impl CosmeticLoopRate
impl CosmeticLoopRate
Sourcepub const FLOOR_HZ: f32 = 10.0
pub const FLOOR_HZ: f32 = 10.0
The floor every constructed rate clamps up to — below this a “cosmetic” pace reads as stutter rather than a deliberate cap.
Sourcepub const fn new(hz: f32) -> Self
pub const fn new(hz: f32) -> Self
Builds a rate, clamping hz up to FLOOR_HZ (no
uncapped/zero value is representable). const fn so every
MotionScheme baseline constructor below can stay const.
The clamp is NaN-safe: a plain hz < FLOOR_HZ test lets NaN
slip through (every ordered comparison with NaN is false), so NaN
is caught explicitly and clamped to the floor alongside any finite
below-floor value. This matters because the desktop shell derives its
per-frame paced interval as Duration::from_secs_f32(1.0 / hz()), and
from_secs_f32 panics on a NaN argument — clamping here guarantees a
finite, >= FLOOR_HZ rate so that division can never produce one. (The
equivalent !(hz >= FLOOR_HZ) one-liner is clearer intent-wise but
trips clippy’s neg_cmp_op_on_partial_ord; the explicit is_nan()
disjunction below is the lint-clean form of the same NaN-safe clamp.)