pub struct Clock(/* private fields */);Expand description
The time an engine runs on: the system’s, or a manual clock that moves only when told, shared by the threads that drive the engine (a test’s).
Implementations§
Source§impl Clock
impl Clock
Sourcepub fn manual(start: SystemTime) -> Clock
pub fn manual(start: SystemTime) -> Clock
A manual clock standing at the wall time start, which moves only
when told.
Sourcepub fn with_frames(self) -> Clock
pub fn with_frames(self) -> Clock
A manual clock that also moves by a frame’s time
(FRAME) with each frame the display shows its engine, before
the frame runs: a test’s app on a real platform, whose time passes
while it animates and stands still while it is idle, as a headless
run’s does. Nothing for the system’s clock.
Sourcepub fn moves_with_frames(&self) -> bool
pub fn moves_with_frames(&self) -> bool
Whether it is a manual clock that moves with the display’s frames
(Clock::with_frames).
Sourcepub fn set_system_time(&self, at: SystemTime)
pub fn set_system_time(&self, at: SystemTime)
Sets a manual clock’s wall time (Date.now()) to at, without
moving its instants: no timer comes due. Nothing on the system’s.
Sourcepub fn advance_to(&self, at: Instant)
pub fn advance_to(&self, at: Instant)
Moves a manual clock forward to at (never back), and runs the
alarms due by then, in order. Nothing on the system’s.
Sourcepub fn at(&self, at: Instant, alarm: impl FnOnce() + Send + 'static)
pub fn at(&self, at: Instant, alarm: impl FnOnce() + Send + 'static)
Runs alarm once the clock reaches at: on a thread of its own
for the system’s clock, when it is moved past at for a manual
one.
Sourcepub fn next_alarm(&self) -> Option<Instant>
pub fn next_alarm(&self) -> Option<Instant>
When a manual clock’s next alarm is due.