aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-11-03 02:23:15 +0100
committerTeddy Wing2018-11-03 02:23:15 +0100
commit226c48b851351fcb3755953be61e102baa57f4cf (patch)
tree64686f3b0e699872d82ee52c7cb39bcd3897e347
parent20675d6b78e666c9fcfdb22a003a098b117dd74e (diff)
downloaddome-key-map-226c48b851351fcb3755953be61e102baa57f4cf.tar.bz2
run_key_action(): Use `Result` from `run_action()`
Now that `run_action()` returns a `Result` (e4c21b11069297d289f25834cfc3c001a4604b5f), we need to use that `Result` when we call it in `run_key_action()`. Pass on the `Result` to `ffi::run_key_action()`, and print the error message from there.
-rw-r--r--src/ffi.rs5
-rw-r--r--src/map.rs12
2 files changed, 11 insertions, 6 deletions
diff --git a/src/ffi.rs b/src/ffi.rs
index 238385d..6758a46 100644
--- a/src/ffi.rs
+++ b/src/ffi.rs
@@ -122,7 +122,10 @@ pub extern "C" fn dome_key_run_key_action(
&mut *state
};
- run_key_action(&mut state, trigger, on_mode_change);
+ match run_key_action(&mut state, trigger, on_mode_change) {
+ Ok(_) => (),
+ Err(e) => error!("{}", e),
+ };
}
#[no_mangle]
diff --git a/src/map.rs b/src/map.rs
index 86d6773..7d9cb0f 100644
--- a/src/map.rs
+++ b/src/map.rs
@@ -16,7 +16,7 @@ pub fn run_key_action<'a>(
state: &mut State,
trigger: &'a [HeadphoneButton],
on_mode_change: extern "C" fn(mode_change: ModeChange),
-) {
+) -> Result<()> {
match state.map_group {
Some(ref map_group) => {
let map = map_group.maps.get(trigger);
@@ -30,18 +30,18 @@ pub fn run_key_action<'a>(
on_mode_change(ModeChange::Deactivated);
- return;
+ return Ok(());
}
if let Some(map) = mode.get(trigger) {
- run_action(&map);
+ run_action(&map)?;
}
}
}
if state.in_mode.is_none() {
if let Some(map) = map {
- run_action(&map);
+ run_action(&map)?;
}
}
@@ -52,7 +52,9 @@ pub fn run_key_action<'a>(
}
},
None => (),
- }
+ };
+
+ Ok(())
}
fn run_action(map_action: &MapAction) -> Result<()> {