chore: set result return type to stop function on linux
Co-authored-by: Pariring <parangee9706@gmail.com>pull/11/head
parent
aa1ac62745
commit
d698d4cf56
|
@ -13,6 +13,6 @@ pub fn run(callback: fn(Event)) -> Result<(), Error> {
|
||||||
platforms::run(callback)
|
platforms::run(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn stop() {
|
pub fn stop() -> Result<(), Error> {
|
||||||
platforms::stop()
|
platforms::stop()
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ pub fn start(callback: fn(Event)) -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if filename.starts_with("event") {
|
if filename.starts_with("event") {
|
||||||
|
// TODO: Use Builder::new().spawn to prevent panic
|
||||||
thread::spawn(move || start_reader(format!("/dev/input/{}", filename), callback));
|
thread::spawn(move || start_reader(format!("/dev/input/{}", filename), callback));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +37,7 @@ pub fn start(callback: fn(Event)) -> Result<(), Error> {
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn stop() {
|
pub fn stop() -> Result<(), Error> {
|
||||||
let token = unsafe { &CANCELLATION_TOKEN };
|
let token = unsafe { &CANCELLATION_TOKEN };
|
||||||
|
|
||||||
if let Some(token) = token {
|
if let Some(token) = token {
|
||||||
|
@ -45,5 +46,9 @@ pub fn stop() {
|
||||||
unsafe {
|
unsafe {
|
||||||
CANCELLATION_TOKEN = None;
|
CANCELLATION_TOKEN = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Err(Error {message: String::from("Hook cannot be stopped before starting.")})
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub fn run(callback: fn(Event)) -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub fn stop() {
|
pub fn stop() -> Result<(), Error> {
|
||||||
linux::stop()
|
linux::stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue