aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorTeddy Wing2018-08-16 13:16:38 +0200
committerTeddy Wing2018-08-16 13:16:38 +0200
commit33f8d8cea1eb67fe9f73aad34891b85ccf37e4cc (patch)
treeb3ffa211ccab2a7bdb022b54e1fa304e2ade0e26 /src/lib.rs
parent88b9809210182dbd7e4c70dab91165b749e81d5a (diff)
downloaddome-key-map-33f8d8cea1eb67fe9f73aad34891b85ccf37e4cc.tar.bz2
New `Map` struct; Rename existing `Map` struct to `MapAction`
Add a new `Map` type that includes a field for `trigger`. This allows us to parse a single map definition line into a single struct, making parsing more granular than going directly to `MapCollection`. Rename the existing `Map` type to `MapAction` to support this change.
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs
index d10edd1..79941d1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -30,11 +30,18 @@ pub enum MapKind {
}
#[derive(Debug)]
-pub struct Map {
+pub struct MapAction {
pub action: Action,
pub kind: MapKind,
}
-type MapCollection = HashMap<Trigger, Map>;
+
+struct Map {
+ trigger: Trigger,
+ action: Action,
+ kind: MapKind,
+}
+
+type MapCollection = HashMap<Trigger, MapAction>;
pub struct DKMapGroup {
maps: MapCollection,
@@ -118,7 +125,7 @@ where
for (_, _, kind, _, trigger, _, action, _) in collection {
maps.insert(
trigger,
- Map {
+ MapAction {
action: action,
kind: kind,
}
@@ -199,14 +206,14 @@ cmd <down> /usr/bin/say 'hello'
let mut expected = HashMap::new();
expected.insert(
vec![HeadphoneButton::Up, HeadphoneButton::Down],
- Map {
+ MapAction {
action: "test".to_owned(),
kind: MapKind::Map,
},
);
expected.insert(
vec![HeadphoneButton::Down],
- Map {
+ MapAction {
action: "/usr/bin/say 'hello'".to_owned(),
kind: MapKind::Command,
},