pub trait Clock: Send + Sync {
// Required methods
fn monotonic(&self) -> f64;
fn sleep(&self, seconds: f64);
fn sleep_async<'a>(
&'a self,
seconds: f64,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>;
}Expand description
A monotonic time source. The pool uses the injected clock for logical time (connection
age, idle time, breaker recovery, retry backoff); real-time blocking in the async pool is
driven by the runtime, not the clock (exactly as Python’s asyncio.timeout ignores the
injected clock).
Required Methods§
Sourcefn sleep_async<'a>(
&'a self,
seconds: f64,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>
fn sleep_async<'a>( &'a self, seconds: f64, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>
Async sleep for the given number of seconds. For SystemClock this awaits a real
timer; for ManualClock it advances logical time and returns immediately.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".