Skip to main content

notifications/
urgency.rs

1use crate::private_prelude::*;
2/// The urgency level of the notification.
3///
4/// Represents how important is the notification and may affect how it's displayed in the graphical
5/// interface.
6#[derive(Copy, Clone, Serialize, Deserialize, Debug)]
7pub enum Urgency {
8    /// A low level of urgency.
9    ///
10    /// Notification does not require immediate user attention.
11    Low,
12
13    /// A normal level of urgency.
14    ///
15    /// For example, a notification about new message from a chat app.
16    Normal,
17
18    /// A critical level of urgency.
19    ///
20    /// The notification requires user attention and should stand out from the rest of
21    /// notifications.
22    Critical,
23}
24
25impl From<u8> for Urgency {
26    fn from(value: u8) -> Self {
27        match value {
28            0 => Self::Low,
29            1 => Self::Normal,
30            2 => Self::Critical,
31            _ => Self::Low, // fallback
32        }
33    }
34}
35
36impl From<Urgency> for u8 {
37    fn from(value: Urgency) -> Self {
38        match value {
39            Urgency::Low => 0,
40            Urgency::Normal => 1,
41            Urgency::Critical => 2,
42        }
43    }
44}