pub trait TimeSource<T> {
// Required method
fn current_millis(&self) -> T;
}Expand description
A trait for time sources that return a monotonic or wall-clock timestamp.
This abstraction allows you to plug in a real system clock, a monotonic timer, or a mocked time source in tests.
The timestamp type T is generic (typically u64 or u128), and the unit
is expected to be milliseconds relative to a configurable origin.
§Example
use ferroid::TimeSource;
struct FixedTime;
impl TimeSource<u64> for FixedTime {
fn current_millis(&self) -> u64 {
1234
}
}
let time = FixedTime;
assert_eq!(time.current_millis(), 1234);Required Methods§
Sourcefn current_millis(&self) -> T
fn current_millis(&self) -> T
Returns the current time in milliseconds since the configured epoch.