pub struct DynTimeProvider(Impl);
Expand description
Type-erased SleepProvider
and CoarseTimeProvider
Useful where time is needed, but we don’t want a runtime type parameter.
Tuple Fields§
§0: Impl
Implementations§
Source§impl DynTimeProvider
impl DynTimeProvider
Sourcepub fn new<R: SleepProvider + CoarseTimeProvider>(runtime: R) -> Self
pub fn new<R: SleepProvider + CoarseTimeProvider>(runtime: R) -> Self
Create a new DynTimeProvider
from a concrete runtime type
Trait Implementations§
Source§impl Clone for DynTimeProvider
impl Clone for DynTimeProvider
Source§fn clone(&self) -> DynTimeProvider
fn clone(&self) -> DynTimeProvider
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl CoarseTimeProvider for DynTimeProvider
impl CoarseTimeProvider for DynTimeProvider
Source§fn now_coarse(&self) -> CoarseInstant
fn now_coarse(&self) -> CoarseInstant
Return the
CoarseTimeProvider
’s view of the current instant. Read moreSource§impl Debug for DynTimeProvider
impl Debug for DynTimeProvider
Source§impl SleepProvider for DynTimeProvider
impl SleepProvider for DynTimeProvider
Source§type SleepFuture = Pin<Box<dyn Future<Output = ()> + Send>>
type SleepFuture = Pin<Box<dyn Future<Output = ()> + Send>>
A future returned by
SleepProvider::sleep()
Source§fn wallclock(&self) -> SystemTime
fn wallclock(&self) -> SystemTime
Return the SleepProvider’s view of the current wall-clock time. Read more
Source§fn block_advance<R: Into<String>>(&self, reason: R)
fn block_advance<R: Into<String>>(&self, reason: R)
Signify that a test running under mock time shouldn’t advance time yet, with a given
unique reason string. This is useful for making sure (mock) time doesn’t advance while
things that might require some (real-world) time to complete do so, such as spawning a task
on another thread. Read more
Source§fn release_advance<R: Into<String>>(&self, reason: R)
fn release_advance<R: Into<String>>(&self, reason: R)
Signify that the reason to withhold time advancing provided in a call to
block_advance
no
longer exists, and it’s fine to move time forward if nothing else is blocking advances. Read moreSource§fn allow_one_advance(&self, duration: Duration)
fn allow_one_advance(&self, duration: Duration)
Allow a test running under mock time to advance time by the provided duration, even if the
above
block_advance
API has been used. Read moreAuto Trait Implementations§
impl Freeze for DynTimeProvider
impl !RefUnwindSafe for DynTimeProvider
impl Send for DynTimeProvider
impl Sync for DynTimeProvider
impl Unpin for DynTimeProvider
impl !UnwindSafe for DynTimeProvider
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> SleepProviderExt for Twhere
T: SleepProvider,
impl<T> SleepProviderExt for Twhere
T: SleepProvider,
Source§fn timeout<F: Future>(
&self,
duration: Duration,
future: F,
) -> Timeout<F, Self::SleepFuture> ⓘ
fn timeout<F: Future>( &self, duration: Duration, future: F, ) -> Timeout<F, Self::SleepFuture> ⓘ
Source§fn sleep_until_wallclock(
&self,
when: SystemTime,
) -> SleepUntilWallclock<'_, Self> ⓘ
fn sleep_until_wallclock( &self, when: SystemTime, ) -> SleepUntilWallclock<'_, Self> ⓘ
Pause until the wall-clock is at
when
or later, trying to
recover from clock jumps. Read more