Debian Codegraph @

examples/urgency.rs

raw symbols SCIP
1 #[cfg(target_os = "macos")]
2 fn main() {
3 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Urgency is not supported on macOS")
4 }
5
6 #[cfg(any(all(unix, not(target_os = "macos")), target_os = "windows"))]
7 fn mainrust-analyzer cargo notify-rust 4.18.0 main().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> {
8 use notify_rustrust-analyzer cargo notify-rust 4.18.0 crate/::{Notificationrust-analyzer cargo notify-rust 4.18.0 notification/Notification#, Urgencyrust-analyzer cargo notify-rust 4.18.0 urgency/Urgency#::*};
9
10 #[cfg(all(unix, not(target_os = "macos")))]
11 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Testing urgency on Linux/BSD (XDG)");
12 #[cfg(all(unix, not(target_os = "macos")))]
13 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Urgency is sent as a hint. Critical notifications should not timeout.\n");
14
15 #[cfg(target_os = "windows")]
16 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Testing urgency on Windows");
17 #[cfg(target_os = "windows")]
18 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Low/Normal → Default scenario, Critical → Reminder scenario (stays on screen)\n");
19
20 // Test all urgency levels
21 for urgency in &[Lowrust-analyzer cargo notify-rust 4.18.0 urgency/Urgency#Low#, Normalrust-analyzer cargo notify-rust 4.18.0 urgency/Urgency#Normal#, Criticalrust-analyzer cargo notify-rust 4.18.0 urgency/Urgency#Critical#] {
22 let mut notification = Notificationrust-analyzer cargo notify-rust 4.18.0 notification/Notification#::newrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]new().();
23 notification
24 .summaryrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]summary().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Urgency {:?}", urgency))
25 .bodyrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]body().("This notification demonstrates urgency levels")
26 .urgencyrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]urgency().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().urgency);
27
28 #[cfg(all(unix, not(target_os = "macos")))]
29 notification.iconrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]icon().("firefox");
30
31 notification.showrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]show().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
32 }
33
34 // Test urgency from string
35 let mut notification = Notificationrust-analyzer cargo notify-rust 4.18.0 notification/Notification#::newrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]new().();
36 notification
37 .summaryrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]summary().("Urgency from String")
38 .bodyrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]body().("This uses 'high' which maps to Critical")
39 .urgencyrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]urgency().("high".try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().);
40
41 #[cfg(all(unix, not(target_os = "macos")))]
42 notification.iconrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]icon().("dialog-warning");
43
44 notification.showrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]show().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
45
46 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
47 }