Support triggering multiple actions

This commit is contained in:
Sam W 2022-07-08 14:01:09 +01:00
parent d4a0a1e992
commit 14e9860697
2 changed files with 9 additions and 1 deletions

View File

@ -27,6 +27,13 @@ impl fmt::Display for Action {
#[derive(Deserialize, StaticType, Debug)] #[derive(Deserialize, StaticType, Debug)]
pub struct Actions(Vec<Action>); pub struct Actions(Vec<Action>);
impl Actions {
// Return the iterator over the inner Vec of Actions
pub fn iter(&self) -> std::slice::Iter<Action> {
self.0.iter()
}
}
impl fmt::Display for Actions { impl fmt::Display for Actions {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Actions(count={})", self.0.len()) write!(f, "Actions(count={})", self.0.len())

View File

@ -90,7 +90,8 @@ impl<'a> State<'a> {
fn execute_mapping(&mut self, mapping: &Mapping) { fn execute_mapping(&mut self, mapping: &Mapping) {
match mapping { match mapping {
Mapping::Trigger(t) => self.execute_action(t), Mapping::Trigger(act) => self.execute_action(act),
Mapping::TriggerMulti(acts) => acts.iter().map(|a| self.execute_action(a)).collect(),
_ => event!(Level::WARN, %mapping, "Ignoring unimplemented mapping"), _ => event!(Level::WARN, %mapping, "Ignoring unimplemented mapping"),
} }
} }