vizia_core/input/
entry.rs
1use crate::context::EventContext;
2
3#[derive(Copy, Clone)]
8pub struct KeymapEntry<T>
9where
10 T: 'static + Clone + PartialEq + Send + Sync,
11{
12 action: T,
13 on_action: fn(&mut EventContext),
14}
15
16impl<T> KeymapEntry<T>
17where
18 T: 'static + Clone + PartialEq + Send + Sync,
19{
20 pub fn new(action: T, on_action: fn(&mut EventContext)) -> Self {
35 Self { action, on_action }
36 }
37
38 pub fn action(&self) -> &T {
40 &self.action
41 }
42
43 pub fn on_action(&self) -> &fn(&mut EventContext) {
45 &self.on_action
46 }
47}
48
49impl<T> PartialEq for KeymapEntry<T>
50where
51 T: 'static + Clone + PartialEq + Send + Sync,
52{
53 fn eq(&self, other: &Self) -> bool {
54 self.action == other.action
55 }
56}
57
58impl<T> PartialEq<T> for KeymapEntry<T>
59where
60 T: 'static + Clone + PartialEq + Send + Sync,
61{
62 fn eq(&self, other: &T) -> bool {
63 self.action == *other
64 }
65}