chore: set result return type to stop function on linux

Co-authored-by: Pariring <parangee9706@gmail.com>
pull/11/head
CrackThrough 2022-11-02 18:35:45 +09:00 committed by Pariring
parent aa1ac62745
commit d698d4cf56
Signed by: pikokr
GPG Key ID: DB839724AD14EC9F
3 changed files with 8 additions and 3 deletions

View File

@ -13,6 +13,6 @@ pub fn run(callback: fn(Event)) -> Result<(), Error> {
platforms::run(callback)
}
pub fn stop() {
pub fn stop() -> Result<(), Error> {
platforms::stop()
}

View File

@ -27,6 +27,7 @@ pub fn start(callback: fn(Event)) -> Result<(), Error> {
}
if filename.starts_with("event") {
// TODO: Use Builder::new().spawn to prevent panic
thread::spawn(move || start_reader(format!("/dev/input/{}", filename), callback));
}
}
@ -36,7 +37,7 @@ pub fn start(callback: fn(Event)) -> Result<(), Error> {
// TODO
#[allow(dead_code)]
pub fn stop() {
pub fn stop() -> Result<(), Error> {
let token = unsafe { &CANCELLATION_TOKEN };
if let Some(token) = token {
@ -45,5 +46,9 @@ pub fn stop() {
unsafe {
CANCELLATION_TOKEN = None;
}
return Ok();
}
Err(Error {message: String::from("Hook cannot be stopped before starting.")})
}

View File

@ -11,7 +11,7 @@ pub fn run(callback: fn(Event)) -> Result<(), Error> {
}
#[cfg(target_os = "linux")]
pub fn stop() {
pub fn stop() -> Result<(), Error> {
linux::stop()
}