pub trait InputClock {
// Required method
fn now(&self) -> EventTime;
// Provided methods
fn epoch(&self) -> Option<Instant> { ... }
fn advance(&self, d: Duration) { ... }
}Expand description
The source of EventTimes for one tree.
&self rather than &mut self so a clock can be shared through an Rc and
read from anywhere in a dispatch without threading a mutable borrow.
Required Methods§
Provided Methods§
Sourcefn epoch(&self) -> Option<Instant>
fn epoch(&self) -> Option<Instant>
The real instant this clock’s EventTime::ZERO corresponds to, for a
clock that has one.
None for a clock with no wall-clock anchor (ManualClock). The
framework reads it in exactly one place — to assert that the input
timeline and the tree’s simulated clock share an origin — and a backend
may read it to convert an OS timestamp into an EventTime.
Sourcefn advance(&self, d: Duration)
fn advance(&self, d: Duration)
Move this clock forward by d, for a clock that has to be moved.
A no-op by default, which is right for MonotonicClock: it already
advances on its own, and shifting its epoch would make every pending
deadline fire the moment a test nudged the simulated clock for an
unrelated reason. ManualClock overrides it, so
WidgetTree::advance_time moves the
input timeline and the simulated one together and a fling advances by
exactly the duration the caller named.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".