Debian Codegraph @

examples/update.rs

raw symbols SCIP
1 #![allow(dead_code)]
2 use notify_rustrust-analyzer cargo notify-rust 4.18.0 crate/::Notificationrust-analyzer cargo notify-rust 4.18.0 notification/Notification#;
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#;
4
5 #[cfg(target_os = "windows")]
6 fn main() {
7 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("This is not a windows feature")
8 }
9
10 #[cfg(all(unix, not(target_os = "macos")))]
11 fn update_via_handlerust-analyzer cargo notify-rust 4.18.0 update_via_handle().() {
12 let mut notification_handle = Notificationrust-analyzer cargo notify-rust 4.18.0 notification/Notification#::newrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]new().()
13 .summaryrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]summary().("First Notification")
14 .bodyrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]body().("This notification will be changed!")
15 .iconrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]icon().("dialog-warning")
16 .showrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]show().()
17 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
18
19 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::threadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/::sleeprust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/functions/sleep().(Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_millis().(1_500));
20
21 notification_handle
22 .appnamerust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]appname().("foo") // changing appname to keep plasma from merging the new and the old one
23 .iconrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]icon().("dialog-ok")
24 .bodyrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]body().("<b>This</b> has been changed through the notification_handle");
25
26 notification_handle.updaterust-analyzer cargo notify-rust 4.18.0 xdg/impl#[NotificationHandle]update().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
27 }
28
29 #[allow(dead_code)]
30 #[cfg(all(unix, not(target_os = "macos")))]
31 fn update_via_manually_stored_idrust-analyzer cargo notify-rust 4.18.0 update_via_manually_stored_id().() {
32 let handle = Notificationrust-analyzer cargo notify-rust 4.18.0 notification/Notification#::newrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]new().()
33 .summaryrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]summary().("First Notification")
34 .bodyrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]body().("This notification will be changed!")
35 .iconrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]icon().("dialog-warning")
36 .showrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]show().()
37 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
38
39 let id = handle.idrust-analyzer cargo notify-rust 4.18.0 xdg/impl#[NotificationHandle]id().();
40 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::threadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/::sleeprust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/functions/sleep().(Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_millis().(1_500));
41
42 Notificationrust-analyzer cargo notify-rust 4.18.0 notification/Notification#::newrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]new().()
43 .appnamerust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]appname().("foo") // changing appname to keep plasma from merging the new and the old one
44 .iconrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]icon().("dialog-ok")
45 .bodyrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]body().("<b>This</b> has been changed by sending a new notification with the same id")
46 .idrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]id().(id)
47 .showrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]show().()
48 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
49 }
50
51 fn recycling_one_idrust-analyzer cargo notify-rust 4.18.0 recycling_one_id().() {
52 for i in 1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5 {
53 let id = 6666; // you should probably not do this at all
54 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::threadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/::sleeprust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/functions/sleep().(Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_millis().(500));
55 Notificationrust-analyzer cargo notify-rust 4.18.0 notification/Notification#::newrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]new().()
56 .iconrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]icon().("dialog-ok")
57 .bodyrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]body().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("notification{i}"))
58 .idrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]id().(id)
59 .showrust-analyzer cargo notify-rust 4.18.0 notification/impl#[Notification]show().()
60 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
61 }
62 }
63
64 #[cfg(target_os = "macos")]
65 fn main() {
66 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("this is a xdg only feature")
67 }
68
69 #[cfg(all(unix, not(target_os = "macos")))]
70 fn mainrust-analyzer cargo notify-rust 4.18.0 main().() {
71 // please use the handle to update a notification
72 update_via_handlerust-analyzer cargo notify-rust 4.18.0 update_via_handle().();
73
74 //// If your really have to, store the if yourself
75 // update_via_manually_stored_id();
76
77 //// or come up with your own don't do this:
78 recycling_one_idrust-analyzer cargo notify-rust 4.18.0 recycling_one_id().()
79 }