Skip to main content

irtt_client/
timing.rs

1use std::time::{Instant, SystemTime};
2
3/// Client-side timestamp captured in both wall-clock and monotonic time.
4///
5/// Wall-clock time is used for protocol timestamp comparison and one-way delay
6/// calculations. Monotonic time is used for elapsed client-side timing such as
7/// RTT, scheduling, and timeouts.
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub struct ClientTimestamp {
10    /// System wall-clock time.
11    pub wall: SystemTime,
12    /// Monotonic timestamp sampled alongside [`wall`](Self::wall).
13    pub mono: Instant,
14}
15
16impl ClientTimestamp {
17    /// Capture the current wall-clock and monotonic timestamps.
18    pub fn now() -> Self {
19        Self {
20            wall: SystemTime::now(),
21            mono: Instant::now(),
22        }
23    }
24}