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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
use serde::{Deserialize, Serialize};
#[derive(Debug, Default, Clone, Copy, PartialEq, Hash, Serialize, Deserialize)]
pub enum Command {
#[default]
Nop,
Quit,
NextSong,
PrevSong,
TogglePause,
ToggleLoop,
SeekForward,
SeekBackward,
OpenInBrowser,
CopyUrl,
CopyTitle,
VolumeUp,
VolumeDown,
Mute,
ToggleVisualizer,
NextSortingMode,
OpenHelpModal,
OpenHotkeyModal,
/// Rename selected song or playlist
Rename,
/// Delete selected song or playlist
Delete,
/// Swap the selected song with the one below it
SwapSongDown,
/// Swap the selected song with the one above it
SwapSongUp,
/// Shuffle current playlist
Shuffle,
/// Select next item (like a song or playlist)
SelectNext,
/// Select previous item (like a song or playlist)
SelectPrev,
/// Select the pane to the right (the same as pressing the \<right> key)
SelectRight,
/// Select the pane to the left (the same as pressing the \<left> key)
SelectLeft,
/// Add a new song or playlist
Add,
/// Add song to the queue
QueueSong,
/// Add all shown songs to the queue
QueueShown,
/// Queries the user for a song to play, without adding it to a playlist
PlayFromModal,
/// Open the playlist file in the configured by the environment variable `EDITOR`.
OpenInEditor,
/// Filter/search the selected pane (playlists or songs).
/// The same as pressing '/'
Search,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_serialization() {
// not sure why serde_yaml puts a newline there ¯\_(ツ)_/¯
assert_eq!(serde_yaml::to_string(&Command::Quit).unwrap(), "Quit\n");
assert_eq!(
serde_yaml::to_string(&Command::TogglePause).unwrap(),
"TogglePause\n"
);
}
#[test]
fn test_deserialization() {
assert_eq!(
serde_yaml::from_str::<Command>("Quit").unwrap(),
Command::Quit
);
assert_eq!(
serde_yaml::from_str::<Command>("VolumeUp").unwrap(),
Command::VolumeUp
);
}
}