pub struct MockClock { /* private fields */ }Expand description
Test clock storing wall-clock milliseconds since the UNIX epoch.
Implementations§
Source§impl MockClock
impl MockClock
Sourcepub fn new_at_millis(millis: u64) -> Self
pub fn new_at_millis(millis: u64) -> Self
Create a new clock fixed at the given wall-clock time in milliseconds since the UNIX epoch.
Sourcepub fn new_at_secs(secs: u64) -> Self
pub fn new_at_secs(secs: u64) -> Self
Create a new clock fixed at the given wall-clock time in seconds since the UNIX epoch.
Sourcepub fn set_millis(&self, millis: u64)
pub fn set_millis(&self, millis: u64)
Set the clock to the given wall-clock time in milliseconds since the UNIX epoch.
Trait Implementations§
Source§impl Clock for MockClock
impl Clock for MockClock
Source§fn now(&self) -> Instant
fn now(&self) -> Instant
Monotonic timestamp suitable for measuring durations between two reads.
Source§fn delay(&self, dur: Duration) -> BoxedDelay
fn delay(&self, dur: Duration) -> BoxedDelay
Future that resolves after
dur has elapsed in this clock’s frame.Source§fn duration_since_epoch(&self) -> Duration
fn duration_since_epoch(&self) -> Duration
Wall-clock duration since the UNIX epoch. Used for slot math and persistence
timestamps; not monotonic. Callers pick a granularity (
as_secs, as_millis)
at the call site.Auto Trait Implementations§
impl Freeze for MockClock
impl RefUnwindSafe for MockClock
impl Send for MockClock
impl Sync for MockClock
impl Unpin for MockClock
impl UnwindSafe for MockClock
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
Mutably borrows from an owned value. Read more