too/backend/command.rs
1#[derive(Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)]
2#[non_exhaustive]
3/// Commands are requests sent to the backend
4pub enum Command {
5 /// Set the title to this string
6 SetTitle(String),
7 /// Switch to the main screen (e.g. the screen the backend isn't using)
8 SwitchMainScreen,
9 /// Switch to the alt screen (e.g. the screen the backend is using)
10 SwitchAltScreen,
11 /// Request the backend to quit
12 RequestQuit,
13}
14
15impl Command {
16 /// Set the title to this string
17 pub fn set_title(title: impl ToString) -> Self {
18 Self::SetTitle(title.to_string())
19 }
20
21 /// Switch to the main screen (e.g. the screen the backend isn't using)
22 pub const fn switch_alt_screen() -> Self {
23 Self::SwitchAltScreen
24 }
25
26 /// Switch to the alt screen (e.g. the screen the backend is using)
27 pub const fn switch_main_screen() -> Self {
28 Self::SwitchMainScreen
29 }
30
31 /// Request the backend to quit
32 pub const fn request_quit() -> Self {
33 Self::RequestQuit
34 }
35}