Skip to main content

CosmeticLoopRate

Struct CosmeticLoopRate 

Source
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

Source

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.

Source

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

Source

pub const fn hz(self) -> f32

The clamped rate, in Hz.

Trait Implementations§

Source§

impl Clone for CosmeticLoopRate

Source§

fn clone(&self) -> Self

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 CosmeticLoopRate

Source§

impl Debug for CosmeticLoopRate

Source§

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

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

impl PartialEq for CosmeticLoopRate

Source§

fn eq(&self, other: &Self) -> 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 CosmeticLoopRate

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> ErasedDestructor for T
where T: 'static,

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> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.