pub struct ManualClock { /* private fields */ }Expand description
A deterministic, manually-advanced clock for tests and simulations.
§Example
use grit_core::{Clock, ManualClock};
let c = ManualClock::new(42);
c.set_ms(100);
assert_eq!(c.now_ms(), 100);Implementations§
Source§impl ManualClock
impl ManualClock
Sourcepub fn new(now_ms: TimestampMs) -> Self
pub fn new(now_ms: TimestampMs) -> Self
Create a clock frozen at now_ms.
Sourcepub fn advance_ms(&self, delta_ms: i64)
pub fn advance_ms(&self, delta_ms: i64)
Move the clock forward by delta_ms.
Sourcepub fn set_ms(&self, now_ms: TimestampMs)
pub fn set_ms(&self, now_ms: TimestampMs)
Set the clock to an absolute time.
Trait Implementations§
Source§impl Clock for ManualClock
impl Clock for ManualClock
Source§fn now_ms(&self) -> TimestampMs
fn now_ms(&self) -> TimestampMs
Current wall time in milliseconds since the Unix epoch.
Source§impl Debug for ManualClock
impl Debug for ManualClock
Source§impl Default for ManualClock
impl Default for ManualClock
Source§fn default() -> ManualClock
fn default() -> ManualClock
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for ManualClock
impl RefUnwindSafe for ManualClock
impl Send for ManualClock
impl Sync for ManualClock
impl Unpin for ManualClock
impl UnsafeUnpin for ManualClock
impl UnwindSafe for ManualClock
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