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
32
33
//! Windows-specific extensions.

use crate::ProcessResult;

mod memory;
mod priority;

pub use self::memory::MemoryExt;
pub use self::priority::Priority;

/// Windows-specific extension to [Process].
///
/// [Process]: ../../struct.Process.html
#[async_trait::async_trait]
pub trait ProcessExt {
    /// Get process priority.
    async fn priority(&self) -> ProcessResult<Priority>;

    /// Set process priority.
    async fn set_priority(&self, value: Priority) -> ProcessResult<()>;
}

#[cfg(target_os = "windows")]
#[async_trait::async_trait]
impl ProcessExt for crate::Process {
    async fn priority(&self) -> ProcessResult<Priority> {
        self.as_ref().priority().await
    }

    async fn set_priority(&self, value: Priority) -> ProcessResult<()> {
        self.as_ref().set_priority(value).await
    }
}