pub struct DynTimeProvider(/* private fields */);Expand description
Type-erased SleepProvider and CoarseTimeProvider
Useful where time is needed, but we don’t want a runtime type parameter.
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§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 !RefUnwindSafe for DynTimeProvider
impl !UnwindSafe for DynTimeProvider
impl Forget for DynTimeProvider
impl Freeze for DynTimeProviderwhere
*const ArcInner<Inner<TokioRuntimeHandle, TokioRuntimeHandle, RealCoarseTimeProvider, TokioRuntimeHandle, TokioRuntimeHandle, NativeTlsProvider, TokioRuntimeHandle>> is !null: Freeze,
PhantomData<ArcInner<Inner<TokioRuntimeHandle, TokioRuntimeHandle, RealCoarseTimeProvider, TokioRuntimeHandle, TokioRuntimeHandle, NativeTlsProvider, TokioRuntimeHandle>>>: Freeze,
*const dyn DynProvider is !null: Freeze,
PhantomData<dyn DynProvider>: Freeze,
impl Move for DynTimeProvider
impl Send for DynTimeProviderwhere
Arc<Inner<TokioRuntimeHandle, TokioRuntimeHandle, RealCoarseTimeProvider, TokioRuntimeHandle, TokioRuntimeHandle, NativeTlsProvider, TokioRuntimeHandle>>: Send,
BoxRaw<dyn DynProvider>: Send,
impl Sync for DynTimeProviderwhere
Arc<Inner<TokioRuntimeHandle, TokioRuntimeHandle, RealCoarseTimeProvider, TokioRuntimeHandle, TokioRuntimeHandle, NativeTlsProvider, TokioRuntimeHandle>>: Sync,
BoxRaw<dyn DynProvider>: Sync,
impl Unpin for DynTimeProviderwhere
Arc<Inner<TokioRuntimeHandle, TokioRuntimeHandle, RealCoarseTimeProvider, TokioRuntimeHandle, TokioRuntimeHandle, NativeTlsProvider, TokioRuntimeHandle>>: Unpin,
Box<dyn DynProvider>: Unpin,
impl UnsafeUnpin for DynTimeProviderwhere
*const ArcInner<Inner<TokioRuntimeHandle, TokioRuntimeHandle, RealCoarseTimeProvider, TokioRuntimeHandle, TokioRuntimeHandle, NativeTlsProvider, TokioRuntimeHandle>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Inner<TokioRuntimeHandle, TokioRuntimeHandle, RealCoarseTimeProvider, TokioRuntimeHandle, TokioRuntimeHandle, NativeTlsProvider, TokioRuntimeHandle>>>: UnsafeUnpin,
*const dyn DynProvider is !null: UnsafeUnpin,
PhantomData<dyn DynProvider>: UnsafeUnpin,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 moreimpl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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 moreSource§fn sleep_until(&self, deadline: Instant) -> Self::SleepFuture
fn sleep_until(&self, deadline: Instant) -> Self::SleepFuture
Return a future that will be ready when
deadline is reached. Read more