Update rust, direnv-nix
This commit is contained in:
parent
c3361915a4
commit
d4a0a1e992
4
.envrc
4
.envrc
|
@ -1 +1,5 @@
|
||||||
|
if ! has nix_direnv_version || ! nix_direnv_version 2.1.1; then
|
||||||
|
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.1.1/direnvrc" "sha256-b6qJ4r34rbE23yWjMqbmu3ia2z4b2wIlZUksBke/ol0="
|
||||||
|
fi
|
||||||
use flake
|
use flake
|
||||||
|
export RUST_LOG=info
|
||||||
|
|
18
flake.lock
18
flake.lock
|
@ -36,11 +36,11 @@
|
||||||
},
|
},
|
||||||
"flake-utils_2": {
|
"flake-utils_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1637014545,
|
"lastModified": 1656065134,
|
||||||
"narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=",
|
"narHash": "sha256-oc6E6ByIw3oJaIyc67maaFcnjYOz1mMcOtHxbEf9NwQ=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "bba5dcc8e0b20ab664967ad83d24d64cb64ec4f4",
|
"rev": "bee6a7250dd1b01844a2de7e02e4df7d8a0a206c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -113,11 +113,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_4": {
|
"nixpkgs_4": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1637453606,
|
"lastModified": 1656401090,
|
||||||
"narHash": "sha256-Gy6cwUswft9xqsjWxFYEnx/63/qzaFUwatcbV5GF/GQ=",
|
"narHash": "sha256-bUS2nfQsvTQW2z8SK7oEFSElbmoBahOPtbXPm0AL3I4=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "8afc4e543663ca0a6a4f496262cd05233737e732",
|
"rev": "16de63fcc54e88b9a106a603038dd5dd2feb21eb",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -142,11 +142,11 @@
|
||||||
"nixpkgs": "nixpkgs_4"
|
"nixpkgs": "nixpkgs_4"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1652064227,
|
"lastModified": 1657248581,
|
||||||
"narHash": "sha256-ZpIfELJNVzcxa6+YUr1KfbpTkHh02FASdlHaCC5/Q6w=",
|
"narHash": "sha256-VSAhHCruQCFWzTz7ZSW5QLb2xIKrBGeEyEfKds4MXeY=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "31db726b18ad2620fead6e7cd31b6e57d1cd061b",
|
"rev": "6bd9919005ab6bf72464c9ebdd80f89b0cf82f97",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -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)]
|
#[derive(Deserialize, StaticType, Debug)]
|
||||||
pub enum Mapping {
|
pub enum Mapping {
|
||||||
NOP, // Do nothing.
|
NOP, // Do nothing.
|
||||||
Passthrough, // Passthrough to the layer below
|
Passthrough, // Passthrough to the layer below
|
||||||
Trigger(Action), // Trigger an action
|
Trigger(Action), // Trigger an action
|
||||||
TriggerMulti(Vec<Action>), // Trigger multiple actions in sequence
|
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)]
|
#[derive(Deserialize, Debug)]
|
||||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -1,7 +1,7 @@
|
||||||
mod config;
|
mod config;
|
||||||
mod device;
|
mod device;
|
||||||
|
|
||||||
use config::{Action, Config};
|
use config::{Action, Config, Mapping};
|
||||||
use hidapi::HidApi;
|
use hidapi::HidApi;
|
||||||
use rumqttc::{Client, MqttOptions, QoS};
|
use rumqttc::{Client, MqttOptions, QoS};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -88,10 +88,10 @@ impl<'a> State<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execute_mapping(&mut self, m: &config::Mapping) {
|
fn execute_mapping(&mut self, mapping: &Mapping) {
|
||||||
match m {
|
match mapping {
|
||||||
config::Mapping::Trigger(t) => self.execute_action(t),
|
Mapping::Trigger(t) => self.execute_action(t),
|
||||||
_ => {}
|
_ => event!(Level::WARN, %mapping, "Ignoring unimplemented mapping"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue