Skip to main content

Core

Trait Core 

Source
pub trait Core {
    // Required methods
    fn now(&self) -> Instant;
    fn sleep(&self, dur: Duration) -> BoxFuture<'_, ()>;
    fn next_u64(&self) -> u64;
}
Expand description

The policy engine’s access to time, sleeping, and randomness.

Object-safe by construction. Implementors: TokioCore (default) and TestCore (deterministic, for tests).

Required Methods§

Source

fn now(&self) -> Instant

Current monotonic instant.

Source

fn sleep(&self, dur: Duration) -> BoxFuture<'_, ()>

A future that completes after dur of this Core’s time.

Source

fn next_u64(&self) -> u64

Next pseudo-random u64 (used for jitter). Not cryptographic.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§