Skip to main content

agent_tui_usecases/usecases/ports/
clock.rs

1//! Clock port.
2
3use std::time::Duration;
4use std::time::Instant;
5
6pub trait Clock: Send + Sync {
7    fn now(&self) -> Instant;
8
9    fn elapsed(&self, start: Instant) -> Duration {
10        self.now().duration_since(start)
11    }
12
13    fn elapsed_ms(&self, start: Instant) -> u64 {
14        self.elapsed(start).as_millis() as u64
15    }
16}