1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use heim_common::units::Information;

/// Linux-specific extension to process [Memory] information.
///
/// [Memory]: ../../struct.Memory.html
pub trait MemoryExt {
    /// Returns the amount of memory that could be potentially shared with other processes.
    fn shared(&self) -> Information;

    /// Returns TRS (*text resident set*) - the amount of memory devoted to executable code.
    fn text(&self) -> Information;

    /// Returns DRS (*data resident set*) - the amount of physical memory
    /// devoted to other than executable code.
    fn data(&self) -> Information;
}

#[cfg(target_os = "linux")]
impl MemoryExt for crate::Memory {
    fn shared(&self) -> Information {
        self.as_ref().shared()
    }

    fn text(&self) -> Information {
        self.as_ref().text()
    }

    fn data(&self) -> Information {
        self.as_ref().data()
    }
}