File: timeout.rs

package info (click to toggle)
rust-notify-rust 4.11.6-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 604 kB
  • sloc: sh: 18; makefile: 4
file content (32 lines) | stat: -rw-r--r-- 891 bytes parent folder | download
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
#[cfg(any(target_os = "windows", target_os = "macos"))]
fn main() {
    println!("this is a xdg only feature")
}

#[cfg(all(unix, not(target_os = "macos")))]
fn main() -> Result<(), Box<dyn std::error::Error>> {
    use notify_rust::*;
    use std::time::Duration;

    Notification::new()
        .summary("Notification Duration timeout")
        .body("this one should stay for 2s")
        .icon("timer")
        .timeout(Duration::from_secs(2))
        .show()?;

    Notification::new()
        .summary("Notification ms timeout")
        .body("this one should stay for 2s (2000ms)")
        .icon("timer")
        .timeout(2_000)
        .show()?;

    Notification::new()
        .summary("Notification string timeout")
        .body("this one should stay for 2s (\"2000\")")
        .icon("timer")
        .timeout("2000".parse::<Timeout>().unwrap())
        .show()?;
    Ok(())
}