mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-17 14:21:22 +01:00
feat(platform): a Linux clock kind and Host::is_linux
This commit is contained in:
1 parent
17d44cbcba
commit
b39b17dd6e
2 files changed
+10
No files matched your search
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user