metrale_scheduler/clock.rs
1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3//! 2026-09-25: [`ClockIo`], the injectable clock, and [`SystemClock`], its
4//! implementation over [`Instant::now`].
5//!
6//! Owner: scheduler.
7//! Invariants: none beyond the types.
8
9use std::time::Instant;
10
11pub trait ClockIo: Send + Sync + std::fmt::Debug {
12 fn now(&self) -> Instant;
13}
14
15/// 2026-09-25: The monotonic system clock ([`Instant`]).
16#[derive(Debug, Default)]
17pub struct SystemClock;
18
19impl ClockIo for SystemClock {
20 fn now(&self) -> Instant {
21 Instant::now()
22 }
23}