pub struct CosmeticLoopRate(/* private fields */);Expand description
The design-token vocabulary: the Theme bundle plus its
component token tables, flat-re-exported from frust-theme so app code
never names that crate directly. A root component reads the active theme via
use_context::<Theme>(); a widget reads it during paint/layout via
PaintCtx::theme_as/LayoutCtx::theme_as (or Theme::from_paint_ctx).
Includes the glass material tokens — this crate ships the opaque recipe, and a design system authors its own translucent one over the same types:
use frust::GlassScale;
let glass = GlassScale::opaque_material();
assert_eq!(glass.chrome.blur_radius_intent, 0.0);
assert!(glass.control.is_opaque());Also the composable-theming surface:
ThemeBuilder (defineTheme/copyWith analog), the no-lock-in typed
extension slot (ThemeExtensions) plus its first consumer
StatusPalette/StatusColors (success/warning/info), and the motion
vocabulary (MotionDurations/EasingSet) — all flat-re-exported so an
app (or a design-system plugin) authors a theme against frust::* alone.
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) -> CosmeticLoopRate
pub const fn new(hz: f32) -> CosmeticLoopRate
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.)
Trait Implementations§
Source§impl Clone for CosmeticLoopRate
impl Clone for CosmeticLoopRate
Source§fn clone(&self) -> CosmeticLoopRate
fn clone(&self) -> CosmeticLoopRate
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 CosmeticLoopRate
Source§impl Debug for CosmeticLoopRate
impl Debug for CosmeticLoopRate
Source§impl PartialEq for CosmeticLoopRate
impl PartialEq for CosmeticLoopRate
impl StructuralPartialEq for CosmeticLoopRate
Auto Trait Implementations§
impl Freeze for CosmeticLoopRate
impl RefUnwindSafe for CosmeticLoopRate
impl Send for CosmeticLoopRate
impl Sync for CosmeticLoopRate
impl Unpin for CosmeticLoopRate
impl UnsafeUnpin for CosmeticLoopRate
impl UnwindSafe for CosmeticLoopRate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.