heim_process/os/linux/
mod.rs

1//! Linux-specific extensions.
2
3use heim_common::prelude::{BoxFuture, BoxStream};
4
5use crate::ProcessResult;
6
7mod io_counters;
8mod memory;
9
10pub use self::io_counters::IoCounters;
11pub use self::memory::MemoryExt;
12
13/// Linux-specific extension to [Process]
14///
15/// [Process]: ../../struct.Process.html
16pub trait ProcessExt {
17    /// Returns future which resolves into process IO counters.
18    ///
19    /// Since `-> impl Trait` is not allowed yet in the trait methods,
20    /// this method returns boxed `Future`. This behavior will change later.
21    fn io_counters(&self) -> BoxFuture<ProcessResult<IoCounters>>;
22
23    /// Returns stream which yield this process [IO counters] for each network interface.
24    ///
25    /// Since `-> impl Trait` is not allowed yet in the trait methods,
26    /// this method returns boxed `Stream`. This behavior will change later.
27    ///
28    /// [IO counters]: ./struct.IoCounters.html
29    fn net_io_counters(&self) -> BoxStream<ProcessResult<heim_net::IoCounters>>;
30}
31
32#[cfg(target_os = "linux")]
33impl ProcessExt for crate::Process {
34    fn io_counters(&self) -> BoxFuture<ProcessResult<IoCounters>> {
35        self.as_ref().io_counters()
36    }
37
38    fn net_io_counters(&self) -> BoxStream<ProcessResult<heim_net::IoCounters>> {
39        self.as_ref().net_io_counters()
40    }
41}