diff options
| author | Teddy Wing | 2018-11-03 02:23:15 +0100 |
|---|---|---|
| committer | Teddy Wing | 2018-11-03 02:23:15 +0100 |
| commit | 226c48b851351fcb3755953be61e102baa57f4cf (patch) | |
| tree | 64686f3b0e699872d82ee52c7cb39bcd3897e347 | |
| parent | 20675d6b78e666c9fcfdb22a003a098b117dd74e (diff) | |
| download | dome-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.rs | 5 | ||||
| -rw-r--r-- | src/map.rs | 12 |
2 files changed, 11 insertions, 6 deletions
@@ -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] @@ -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<()> { |
