i3ipc_types/
msg.rs

1//! For sending messages to i3
2#[derive(Eq, PartialEq, Hash, Debug, Clone, Copy)]
3pub enum Msg {
4    RunCommand,
5    Workspaces,
6    Subscribe,
7    Outputs,
8    Tree,
9    Marks,
10    BarConfig,
11    Version,
12    BindingModes,
13    Config,
14    Tick,
15    Sync,
16    BindingState,
17}
18
19impl From<u32> for Msg {
20    fn from(num: u32) -> Self {
21        match num {
22            0 => Msg::RunCommand,
23            1 => Msg::Workspaces,
24            2 => Msg::Subscribe,
25            3 => Msg::Outputs,
26            4 => Msg::Tree,
27            5 => Msg::Marks,
28            6 => Msg::BarConfig,
29            7 => Msg::Version,
30            8 => Msg::BindingModes,
31            9 => Msg::Config,
32            10 => Msg::Tick,
33            11 => Msg::Sync,
34            12 => Msg::BindingState,
35            _ => panic!("Unknown message type found"),
36        }
37    }
38}
39
40impl From<Msg> for u32 {
41    fn from(msg: Msg) -> Self {
42        match msg {
43            Msg::RunCommand => 0,
44            Msg::Workspaces => 1,
45            Msg::Subscribe => 2,
46            Msg::Outputs => 3,
47            Msg::Tree => 4,
48            Msg::Marks => 5,
49            Msg::BarConfig => 6,
50            Msg::Version => 7,
51            Msg::BindingModes => 8,
52            Msg::Config => 9,
53            Msg::Tick => 10,
54            Msg::Sync => 11,
55            Msg::BindingState => 12,
56        }
57    }
58}