pub trait ClockProvider: Send + Sync {
// Required methods
fn now(&self) -> u64;
fn system_time_millis(&self) -> u64;
fn sleep(
&self,
duration: Duration,
) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>;
fn advance(&self, duration: Duration);
fn is_mock(&self) -> bool;
}Expand description
Provider trait for time operations.
This trait abstracts all time-related operations, allowing tests to control time precisely for deterministic behavior.
Required Methods§
Sourcefn system_time_millis(&self) -> u64
fn system_time_millis(&self) -> u64
Get the current system time as milliseconds since UNIX epoch.
Sourcefn sleep(
&self,
duration: Duration,
) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>
fn sleep( &self, duration: Duration, ) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>
Sleep for the specified duration.
In mock implementations, this may return immediately or track pending sleeps for manual advancement.