1use serde::{Deserialize, Serialize};
2use std::str::FromStr;
3
4#[derive(Debug, Default, Clone, Serialize, Deserialize)]
11#[allow(dead_code)]
12pub struct SongInfo {
13 pub artist: String,
14 pub album: String,
15 pub title: String,
16}
17
18#[derive(Debug, Clone, Copy, PartialEq)]
23pub enum PackageShorthand {
24 Off,
25 On,
26 Tiny,
27}
28
29impl FromStr for PackageShorthand {
30 type Err = ();
31
32 fn from_str(s: &str) -> Result<Self, ()> {
33 match s.to_lowercase().as_str() {
34 "off" => Ok(PackageShorthand::Off),
35 "on" => Ok(PackageShorthand::On),
36 "tiny" => Ok(PackageShorthand::Tiny),
37 _ => Ok(PackageShorthand::On),
38 }
39 }
40}
41
42#[derive(Debug, Clone, Copy, PartialEq)]
52pub enum DistroDisplay {
53 Name,
54 NameVersion,
55 NameArch,
56 NameModel,
57 NameModelVersion,
58 NameModelArch,
59 NameModelVersionArch,
60}
61
62impl std::str::FromStr for DistroDisplay {
63 type Err = ();
64
65 fn from_str(s: &str) -> Result<Self, ()> {
66 match s.to_lowercase().as_str() {
67 "name" => Ok(DistroDisplay::Name),
68 "name_version" => Ok(DistroDisplay::NameVersion),
69 "name_arch" => Ok(DistroDisplay::NameArch),
70 "name_model" => Ok(DistroDisplay::NameModel),
71 "name_model_version" => Ok(DistroDisplay::NameModelVersion),
72 "name_model_arch" => Ok(DistroDisplay::NameModelArch),
73 "name_model_version_arch" => Ok(DistroDisplay::NameModelVersionArch),
74 _ => Err(()),
75 }
76 }
77}
78
79#[derive(Debug, Clone, Copy, PartialEq)]
84pub enum UptimeShorthand {
85 Full,
86 Tiny,
87 Seconds,
88}
89
90impl FromStr for UptimeShorthand {
91 type Err = ();
92
93 fn from_str(s: &str) -> Result<Self, Self::Err> {
94 match s.to_lowercase().as_str() {
95 "full" => Ok(UptimeShorthand::Full),
96 "tiny" => Ok(UptimeShorthand::Tiny),
97 "seconds" => Ok(UptimeShorthand::Seconds),
98 _ => Ok(UptimeShorthand::Full),
99 }
100 }
101}
102
103#[derive(Debug, Clone, Copy, PartialEq)]
108pub enum OsAgeShorthand {
109 Full,
110 Tiny,
111 Seconds,
112}
113
114impl FromStr for OsAgeShorthand {
115 type Err = ();
116
117 fn from_str(s: &str) -> Result<Self, Self::Err> {
118 match s.to_lowercase().as_str() {
119 "full" => Ok(Self::Full),
120 "tiny" => Ok(Self::Tiny),
121 "seconds" => Ok(Self::Seconds),
122 _ => Ok(Self::Full),
123 }
124 }
125}
126
127#[derive(Debug, Clone, Copy)]
132pub enum MemoryUnit {
133 MiB,
134 GiB,
135 KiB,
136}
137
138impl FromStr for MemoryUnit {
139 type Err = ();
140
141 fn from_str(s: &str) -> Result<Self, ()> {
142 match s.to_lowercase().as_str() {
143 "mib" => Ok(MemoryUnit::MiB),
144 "gib" => Ok(MemoryUnit::GiB),
145 "kib" => Ok(MemoryUnit::KiB),
146 _ => Ok(MemoryUnit::MiB),
147 }
148 }
149}
150
151#[derive(Debug, Clone, Copy)]
157pub enum DiskSubtitle {
158 Name,
159 Dir,
160 None,
161 Mount,
162}
163
164impl FromStr for DiskSubtitle {
165 type Err = ();
166
167 fn from_str(s: &str) -> Result<Self, Self::Err> {
168 match s.to_lowercase().as_str() {
169 "name" => Ok(DiskSubtitle::Name),
170 "dir" => Ok(DiskSubtitle::Dir),
171 "none" => Ok(DiskSubtitle::None),
172 "mount" => Ok(DiskSubtitle::Mount),
173 _ => Ok(DiskSubtitle::Dir),
174 }
175 }
176}
177
178pub enum DiskDisplay {
185 Info,
186 Percentage,
187 InfoBar,
188 BarInfo,
189 Bar,
190}
191
192impl FromStr for DiskDisplay {
193 type Err = ();
194
195 fn from_str(s: &str) -> Result<Self, Self::Err> {
196 match s.to_lowercase().as_str() {
197 "info" => Ok(DiskDisplay::Info),
198 "percentage" => Ok(DiskDisplay::Percentage),
199 "infobar" => Ok(DiskDisplay::InfoBar),
200 "barinfo" => Ok(DiskDisplay::BarInfo),
201 "bar" => Ok(DiskDisplay::Bar),
202 _ => Ok(DiskDisplay::InfoBar),
203 }
204 }
205}
206
207#[derive(Debug, Clone, Copy)]
213pub enum BatteryDisplayMode {
214 Off,
215 Bar,
216 InfoBar,
217 BarInfo,
218}
219
220impl FromStr for BatteryDisplayMode {
221 type Err = ();
222
223 fn from_str(s: &str) -> Result<Self, ()> {
224 match s.to_lowercase().as_str() {
225 "off" => Ok(BatteryDisplayMode::Off),
226 "bar" => Ok(BatteryDisplayMode::Bar),
227 "infobar" => Ok(BatteryDisplayMode::InfoBar),
228 "barinfo" => Ok(BatteryDisplayMode::BarInfo),
229 _ => Ok(BatteryDisplayMode::BarInfo),
230 }
231 }
232}