pub struct MockClock { /* private fields */ }Expand description
Mock clock with atomic time storage for thread-safe access.
Implementations§
Source§impl MockClock
impl MockClock
Sourcepub fn new(initial_nanos: u128) -> Self
pub fn new(initial_nanos: u128) -> Self
Create a new mock clock starting at the given nanoseconds
Sourcepub fn from_millis(millis: u64) -> Self
pub fn from_millis(millis: u64) -> Self
Create a new mock clock starting at the given milliseconds
Sourcepub fn now_micros(&self) -> u64
pub fn now_micros(&self) -> u64
Get current time in microseconds
Sourcepub fn now_millis(&self) -> u64
pub fn now_millis(&self) -> u64
Get current time in milliseconds
Sourcepub fn set_micros(&self, micros: u64)
pub fn set_micros(&self, micros: u64)
Set time to specific microseconds
Sourcepub fn set_millis(&self, millis: u64)
pub fn set_millis(&self, millis: u64)
Set time to specific milliseconds
Sourcepub fn advance_nanos(&self, nanos: u128)
pub fn advance_nanos(&self, nanos: u128)
Advance time by nanoseconds
Sourcepub fn advance_micros(&self, micros: u64)
pub fn advance_micros(&self, micros: u64)
Advance time by microseconds
Sourcepub fn advance_millis(&self, millis: u64)
pub fn advance_millis(&self, millis: u64)
Advance time by milliseconds
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more