ralertsinua_models/
alert_status.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(
4    Debug,
5    Default,
6    Deserialize,
7    Serialize,
8    Clone,
9    PartialEq,
10    strum_macros::EnumString,
11    strum_macros::EnumProperty,
12    strum_macros::AsRefStr,
13    strum_macros::Display,
14)]
15pub enum AlertStatus {
16    /// Active
17    #[strum(to_string = "Active", props(icon = "🜸", color = "red"))] // 🔴
18    A,
19    /// Partially active
20    #[strum(to_string = "Partial", props(icon = "🌤", color = "yellow"))] // 🟡
21    P,
22    /// No information
23    #[strum(to_string = "No info", props(icon = "🌣", color = "blue"))] // 🟢
24    #[default]
25    N,
26    /// Loading
27    #[strum(to_string = "Loading", props(icon = "↻", color = "gray"))]
28    L,
29    /// Offline
30    #[strum(to_string = "Offline", props(icon = "?", color = "darkgray"))]
31    O,
32}
33
34impl From<char> for AlertStatus {
35    fn from(c: char) -> Self {
36        match c {
37            'A' => AlertStatus::A,
38            'P' => AlertStatus::P,
39            'L' => AlertStatus::L,
40            'O' => AlertStatus::O,
41            _ => AlertStatus::N,
42        }
43    }
44}