Debian Codegraph @

examples/timeout.rs

raw symbols SCIP
1 #[cfg(any(target_os = "windows", target_os = "macos"))]
2 fn main() {
3 println!("this is a xdg only feature")
4 }
5
6 #[cfg(all(unix, not(target_os = "macos")))]
7 fn main() -> Result<(), Box<dyn std::error::Error>> {
8 use notify_rust::*;
9 use std::time::Duration;
10
11 Notification::new()
12 .summary("Notification Duration timeout")
13 .body("this one should stay for 2s")
14 .icon("timer")
15 .timeout(Duration::from_secs(2))
16 .show()?;
17
18 Notification::new()
19 .summary("Notification ms timeout")
20 .body("this one should stay for 2s (2000ms)")
21 .icon("timer")
22 .timeout(2_000)
23 .show()?;
24
25 Notification::new()
26 .summary("Notification string timeout")
27 .body("this one should stay for 2s (\"2000\")")
28 .icon("timer")
29 .timeout("2000".parse::<Timeout>().unwrap())
30 .show()?;
31 Ok(())
32 }