diff --git a/komorebi-recorder/src/clock.rs b/komorebi-recorder/src/clock.rs index 9c3e6863..66668612 100644 --- a/komorebi-recorder/src/clock.rs +++ b/komorebi-recorder/src/clock.rs @@ -16,6 +16,7 @@ //! |---|---|---| //! | [`Mach`](crate::platform::ClockKind::Mach) | `mach` | `mach_absolute_time`, on macOS | //! | [`Qpc`](crate::platform::ClockKind::Qpc) | `qpc` | `QueryPerformanceCounter`, on Windows | +//! | [`Monotonic`](crate::platform::ClockKind::Monotonic) | `monotonic` | `CLOCK_MONOTONIC`, on Linux | //! | [`Std`](crate::platform::ClockKind::Std) | `std` | [`std::time::Instant`] since the first reading in the process, plus one second so that it is never zero, on a host with no capture | //! //! `mach_absolute_time` pauses while the machine sleeps. Whether the Windows counter does is not diff --git a/komorebi-recorder/src/platform/mod.rs b/komorebi-recorder/src/platform/mod.rs index edbaae3f..800f74ee 100644 --- a/komorebi-recorder/src/platform/mod.rs +++ b/komorebi-recorder/src/platform/mod.rs @@ -92,6 +92,8 @@ pub enum ClockKind { Mach, /// `QueryPerformanceCounter`. Qpc, + /// `CLOCK_MONOTONIC`: pauses while the machine is suspended. + Monotonic, /// A host with no capture, which still needs some monotonic clock to run on. Std, } @@ -157,12 +159,19 @@ impl Host { self.os == "windows" } + #[must_use] + /// Returns `true` if and only if this is Linux. + pub fn is_linux(&self) -> bool { + self.os == "linux" + } + /// `macOS 26.0`, `windows 10.0.26100`: for prose. #[must_use] pub fn describe(&self) -> String { let os = match self.os.as_str() { "macos" => "macOS", "windows" => "Windows", + "linux" => "Linux", other => other, }; match &self.os_version {