win7_notifications/
timeout.rs

1// Copyright 2020-2022 Tauri Programme within The Commons Conservancy
2// SPDX-License-Identifier: Apache-2.0
3// SPDX-License-Identifier: MIT
4
5/// Describes the timeout of a notification
6#[derive(Debug, Copy, Clone, PartialEq, Eq)]
7pub enum Timeout {
8    /// Expires according to server default.
9    ///
10    /// 5000ms
11    Default,
12
13    /// Do not expire, user will have to close this manually.
14    Never,
15
16    /// Expire after n milliseconds.
17    Milliseconds(u32),
18}
19impl From<Timeout> for u64 {
20    fn from(timeout: Timeout) -> Self {
21        match timeout {
22            Timeout::Default => 5000,
23            Timeout::Never => 0,
24            Timeout::Milliseconds(ms) => ms as _,
25        }
26    }
27}
28
29impl Default for Timeout {
30    fn default() -> Self {
31        Timeout::Default
32    }
33}