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
#[derive(Eq, PartialEq, Hash, Copy, Clone, Debug)]
pub enum NotificationUrgency {
Low = 0,
Normal = 1,
Critical = 2
}
impl<'a> From<&'a str> for NotificationUrgency {
fn from(string: &'a str) -> NotificationUrgency {
match string.to_lowercase().as_ref() {
"low" |
"lo" => NotificationUrgency::Low,
"normal" |
"medium" => NotificationUrgency::Normal,
"critical" |
"high" |
"hi" => NotificationUrgency::Critical,
_ => unimplemented!()
}
}
}
impl From<Option<u64>> for NotificationUrgency {
fn from(maybe_int: Option<u64>) -> NotificationUrgency {
match maybe_int {
Some(0) => NotificationUrgency::Low,
Some(2) => NotificationUrgency::Critical,
_ => NotificationUrgency::Normal
}
}
}