-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbindings.rs
42 lines (36 loc) · 954 Bytes
/
bindings.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use std::fmt::Display;
use crate::{Definition, ModeInstruction};
#[derive(Debug, PartialEq, Eq)]
pub struct Binding {
pub definition: Definition,
pub command: String,
pub mode_instructions: Vec<ModeInstruction>,
}
impl Binding {
pub fn running<S: AsRef<str>>(command: S) -> BindingBuilder {
BindingBuilder {
command: command.as_ref().to_string(),
}
}
}
pub struct BindingBuilder {
pub command: String,
}
impl BindingBuilder {
pub fn on(self, definition: Definition) -> Binding {
Binding {
definition,
command: self.command,
mode_instructions: vec![],
}
}
}
impl Display for Binding {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"Binding {} \u{2192} {} (mode instructions: {:?})",
self.definition, self.command, self.mode_instructions
)
}
}