pub struct TimeController { /* private fields */ }Expand description
A controller for virtual time in tests
Implementations§
Source§impl TimeController
impl TimeController
Sourcepub fn new_paused() -> Self
pub fn new_paused() -> Self
Create a new time controller with paused time
Sourcepub fn set_scale(&self, scale: f64)
pub fn set_scale(&self, scale: f64)
Set time scale (0.0 = paused, 1.0 = normal, 2.0 = double speed)
Sourcepub fn advance(&self, duration: Duration) -> Result<(), &'static str>
pub fn advance(&self, duration: Duration) -> Result<(), &'static str>
Advance time by the given duration (only works when paused)
Sourcepub async fn sleep(&self, duration: Duration)
pub async fn sleep(&self, duration: Duration)
Sleep for the given duration In paused mode: advances virtual time instantly In real mode: actually sleeps
Sourcepub fn sleep_blocking(&self, duration: Duration)
pub fn sleep_blocking(&self, duration: Duration)
Block the current thread for the given duration In paused mode: advances virtual time instantly In real mode: actually blocks
Trait Implementations§
Source§impl Clone for TimeController
impl Clone for TimeController
Source§fn clone(&self) -> TimeController
fn clone(&self) -> TimeController
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TimeController
impl RefUnwindSafe for TimeController
impl Send for TimeController
impl Sync for TimeController
impl Unpin for TimeController
impl UnsafeUnpin for TimeController
impl UnwindSafe for TimeController
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> Inspectable for T
impl<T> Inspectable for T
Source§fn inspect_if(self, condition: bool, label: &str) -> Selfwhere
Self: Debug,
fn inspect_if(self, condition: bool, label: &str) -> Selfwhere
Self: Debug,
Conditionally inspect this value
Source§fn inspect_with<F>(self, label: &str, f: F) -> Self
fn inspect_with<F>(self, label: &str, f: F) -> Self
Inspect with a custom formatter