#[repr(C)]pub struct CssDuration {
pub inner: u32,
pub unit: CssDurationUnit,
}Expand description
A CSS time duration: a magnitude plus the unit it is counted in.
inner is NOT unconditionally milliseconds — read it together with unit,
or go through CssDuration::millis / CssDuration::ticks, which convert.
The derived Ord compares inner first and only then unit, so it is a
total order for storage/dedup purposes but is NOT a chronological comparison
across units (5ms sorts below 5t purely by field order). Compare
durations chronologically by converting them first, or by handing them to
azul_core::task::Duration, which compares on a canonical scale.
Fields§
§inner: u32Magnitude, counted in unit.
unit: CssDurationUnitThe unit inner is counted in.
Implementations§
Source§impl CssDuration
impl CssDuration
Sourcepub const fn from_millis(ms: u32) -> Self
pub const fn from_millis(ms: u32) -> Self
A duration of ms wall-clock milliseconds.
Sourcepub const fn from_ticks(ticks: u32) -> Self
pub const fn from_ticks(ticks: u32) -> Self
A duration of ticks engine frames (the CSS t unit).
Sourcepub const fn millis(&self) -> u32
pub const fn millis(&self) -> u32
This duration in whole milliseconds, converting ticks at
TICKS_PER_SECOND and truncating toward zero.
Saturates at u32::MAX rather than wrapping: u32::MAX ticks is ~828
days, which does not fit u32 milliseconds.
Sourcepub const fn ticks(&self) -> u32
pub const fn ticks(&self) -> u32
This duration in whole ticks, converting milliseconds at
TICKS_PER_SECOND and truncating toward zero.
Truncation means a sub-frame duration (10ms at 60Hz) is zero ticks,
not one — “how many whole frames fit in this span”.
Trait Implementations§
Source§impl Clone for CssDuration
impl Clone for CssDuration
Source§fn clone(&self) -> CssDuration
fn clone(&self) -> CssDuration
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more