diff options
| author | Teddy Wing | 2018-08-16 13:16:38 +0200 |
|---|---|---|
| committer | Teddy Wing | 2018-08-16 13:16:38 +0200 |
| commit | 33f8d8cea1eb67fe9f73aad34891b85ccf37e4cc (patch) | |
| tree | b3ffa211ccab2a7bdb022b54e1fa304e2ade0e26 /src/lib.rs | |
| parent | 88b9809210182dbd7e4c70dab91165b749e81d5a (diff) | |
| download | dome-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.rs | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -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, }, |
