Move getpid to utils module

This commit is contained in:
Patrick Auernig 2018-03-25 20:55:38 +02:00
parent 54ace3a5e9
commit afe1503ad9
3 changed files with 9 additions and 3 deletions

View File

@ -11,6 +11,7 @@ extern crate libc;
#[macro_use]
mod macros;
mod utils;
mod connection;
mod models;
pub mod client;

View File

@ -1,16 +1,16 @@
use libc::getpid;
use models::Command;
use utils::pid;
#[derive(Debug, Default, Serialize)]
pub struct SetActivityArgs {
pid: u32,
pid: i32,
activity: SetActivity,
}
impl SetActivityArgs {
pub fn command(args: SetActivity) -> Command<Self> {
Command::new("SET_ACTIVITY", Self {
pid: unsafe { getpid() as u32 },
pid: pid(),
activity: args
})
}

5
src/utils.rs Normal file
View File

@ -0,0 +1,5 @@
use libc::getpid;
pub fn pid() -> i32 {
unsafe { getpid() as i32 }
}