pub struct Timestep(/* private fields */);Expand description
The fixed simulation timestep, in nanoseconds. Non-zero by type, so no division in the schedule can trap and no constructor can fail: the type carries the guarantee, so nothing has to check for it.
Implementations§
Source§impl Timestep
impl Timestep
Sourcepub const HZ_60: Self
pub const HZ_60: Self
60 Hz, rounded to whole nanoseconds.
60 Hz is not representable: 60 × 16_666_667 = 1_000_000_020, so
sixty ticks run 20 ns long against the wall. That is closed by
definition rather than by rounding — a step’s sim_time and the
loop’s simulated() are tick × dt, so the simulation’s own clock
is exact by construction and the 20 ns is a property of the wall
clock’s relation to the simulation, never of the simulation’s own
arithmetic. Exact divisors exist (64 Hz = 15_625_000,
125 Hz = 8_000_000) if ticks ever need to land on whole seconds.
pub const fn from_nanos(nanos: NonZeroU64) -> Self
Sourcepub const fn nanos(self) -> NonZeroU64
pub const fn nanos(self) -> NonZeroU64
The timestep in nanoseconds, still carrying its non-zero proof so a consumer computing its own exact interpolation needs no guard.