Update rust, direnv-nix
This commit is contained in:
+28
-4
@@ -24,12 +24,36 @@ impl fmt::Display for Action {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, StaticType, Debug)]
|
||||
pub struct Actions(Vec<Action>);
|
||||
|
||||
impl fmt::Display for Actions {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "Actions(count={})", self.0.len())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, StaticType, Debug)]
|
||||
pub enum Mapping {
|
||||
NOP, // Do nothing.
|
||||
Passthrough, // Passthrough to the layer below
|
||||
Trigger(Action), // Trigger an action
|
||||
TriggerMulti(Vec<Action>), // Trigger multiple actions in sequence
|
||||
NOP, // Do nothing.
|
||||
Passthrough, // Passthrough to the layer below
|
||||
Trigger(Action), // Trigger an action
|
||||
TriggerMulti(Actions), // Trigger multiple actions in sequence
|
||||
}
|
||||
|
||||
impl fmt::Display for Mapping {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
match &self {
|
||||
Mapping::NOP => "NOP".to_owned(),
|
||||
Mapping::Passthrough => "Passthrough".to_owned(),
|
||||
Mapping::Trigger(act) => format!("Trigger({})", act),
|
||||
Mapping::TriggerMulti(acts) => format!("Trigger({})", acts),
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
mod config;
|
||||
mod device;
|
||||
|
||||
use config::{Action, Config};
|
||||
use config::{Action, Config, Mapping};
|
||||
use hidapi::HidApi;
|
||||
use rumqttc::{Client, MqttOptions, QoS};
|
||||
use std::collections::HashMap;
|
||||
@@ -88,10 +88,10 @@ impl<'a> State<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn execute_mapping(&mut self, m: &config::Mapping) {
|
||||
match m {
|
||||
config::Mapping::Trigger(t) => self.execute_action(t),
|
||||
_ => {}
|
||||
fn execute_mapping(&mut self, mapping: &Mapping) {
|
||||
match mapping {
|
||||
Mapping::Trigger(t) => self.execute_action(t),
|
||||
_ => event!(Level::WARN, %mapping, "Ignoring unimplemented mapping"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user