OneLauncher-Cracked/packages/gamemode/src/lib.rs
Pauline 8c99ee1b1f
♻️ refactor: clippy lints
Signed-off-by: Pauline <git@ethanlibs.co>
2024-09-27 06:59:27 +02:00

26 lines
574 B
Rust

#![cfg(target_os = "linux")]
use libc::pid_t;
use std::ffi::c_int;
#[link(name = "stub", kind = "static")]
extern "C" {
fn gamemode_start_for_wrapper(pid: pid_t) -> c_int;
}
pub fn request_start_for_wrapper(pid: u32) -> Result<(), String> {
match pid.try_into() {
Ok(signed) => unsafe {
let result = gamemode_start_for_wrapper(signed);
if result == 0 {
Ok(())
} else {
Err(format!(
"failed to request gamemode for pid {}: {}",
pid, result
))
}
},
Err(e) => Err(format!("failed to request gamemode for pid {}: {}", pid, e)),
}
}