pub struct MockClock { /* private fields */ }Expand description
A mock clock implementation for deterministic testing.
This clock allows time to be advanced explicitly, enabling deterministic scheduling tests without relying on real time progression.
Implementations§
Source§impl MockClock
impl MockClock
Sourcepub fn with_system_time() -> Self
pub fn with_system_time() -> Self
Creates a new mock clock initialized to the current system time.
§Panics
Panics if the system clock reports a time before the Unix epoch (January 1, 1970). This is unreachable on all supported platforms.
Sourcepub fn advance_by(&mut self, seconds: u64)
pub fn advance_by(&mut self, seconds: u64)
Advances the clock by the specified number of seconds.
Sourcepub fn now_system_time(&self) -> SystemTime
pub fn now_system_time(&self) -> SystemTime
Returns the current time as a std::time::SystemTime.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MockClock
impl RefUnwindSafe for MockClock
impl Send for MockClock
impl Sync for MockClock
impl Unpin for MockClock
impl UnsafeUnpin 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