Skip to main content

notifications/
close_reason.rs

1/// A reason why the notification is closed.
2#[derive(Copy, Clone, Debug, PartialEq)]
3pub enum CloseReason {
4    /// Expired timeout. The notification was closed automatically upon expiration of the timeout.
5    Expired,
6
7    /// Dismissed by the user.
8    ///
9    /// Generated by a call to [`crate::NotificationService::dismiss_notification`]
10    /// and [`crate::NotificationHandle::dismiss`]
11    Dismissed,
12
13    /// The application requested to close the notification.
14    DBusCall,
15
16    /// Undefined/reserved reasons.
17    Other,
18}
19
20impl From<u32> for CloseReason {
21    fn from(value: u32) -> Self {
22        match value {
23            1 => Self::Expired,
24            2 => Self::Dismissed,
25            3 => Self::DBusCall,
26            _ => Self::Other,
27        }
28    }
29}
30
31impl From<CloseReason> for u32 {
32    fn from(value: CloseReason) -> Self {
33        match value {
34            CloseReason::Expired => 1,
35            CloseReason::Dismissed => 2,
36            CloseReason::DBusCall => 3,
37            CloseReason::Other => 4,
38        }
39    }
40}