heim_memory/os/
mod.rs

1//! OS-specific extensions.
2//!
3//! These are not cross-platform and their usage should be `cfg`-wrapped.
4
5#[cfg(not(windows))]
6use heim_common::units::Information;
7
8cfg_if::cfg_if! {
9    if #[cfg(target_os = "linux")] {
10        pub mod linux;
11    } else if #[cfg(target_os = "macos")] {
12        pub mod macos;
13    }
14}
15
16/// OS-specific extension to [Swap].
17///
18/// ## Compatibility
19///
20/// Applicable for all supported platforms except Windows.
21///
22/// [Swap]: ../struct.Swap.html
23#[cfg(not(windows))]
24pub trait SwapExt {
25    /// The cumulative amount of information the system has swapped in from disk.
26    fn sin(&self) -> Option<Information>;
27
28    /// The cumulative amount of information the system has swapped out from disk.
29    fn sout(&self) -> Option<Information>;
30}
31
32#[cfg(not(windows))]
33impl SwapExt for crate::Swap {
34    fn sin(&self) -> Option<Information> {
35        self.as_ref().sin()
36    }
37
38    fn sout(&self) -> Option<Information> {
39        self.as_ref().sout()
40    }
41}