pub trait Clock {
// Required method
fn now_unix(&self) -> u64;
// Provided method
fn sleep(&self, dur: Duration) { ... }
}Expand description
Supplies the current time. Injected so time-dependent logic (journal timestamps, run ages) is deterministic under test.
Required Methods§
Provided Methods§
Sourcefn sleep(&self, dur: Duration)
fn sleep(&self, dur: Duration)
Block for dur before returning — the passage of real time, injected so
waits are deterministic and instant under test.
The release engine’s crates.io index-wait (the multi-crate workspace
publish path, crate::release::adapters::cargo) polls between attempts
through this method. The default performs a genuine
std::thread::sleep, so the production Clock waits for real without
implementing anything extra; a deterministic test fake overrides it to
advance a virtual clock instead of sleeping, so a bounded-wait loop
terminates instantly and without a real delay.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".