2 个版本
使用旧的 Rust 2015
0.1.1 | 2018 年 4 月 29 日 |
---|---|
0.1.0 | 2018 年 4 月 29 日 |
#26 在 #desktop-notifications
7KB
77 行
允许重用由 notify-rust
创建的通知,而不是创建新的通知,替换已存在的通知的内容。
示例
单个通知的示例
use notify_rust::*;
use reuse_notification::ReuseNotification;
Notification::new()
.summary("Firefox News")
.body("This will almost look like a real firefox notification.")
.icon("firefox")
.timeout(Timeout::Milliseconds(6000))
.reuse() // <-- instead of `show()`
.unwrap();
不同可重用通知的示例
为了覆盖特定通知,向 .reuse()
提供一个字符串。
后续对 .reuse()
的相同字符串调用将用新的内容替换旧通知实例中的内容。
use notify_rust::*;
use reuse_notification::ReuseNotification;
Notification::new()
.summary("Firefox News")
.body("This will almost look like a real firefox notification.")
.icon("firefox")
.timeout(Timeout::Milliseconds(6000))
.reuse("firefox_notification") // <-- instead of `show()`
.unwrap();
Notification::new()
.summary("Other News")
.body("This will almost look like a real firefox notification.")
.icon("firefox")
.timeout(Timeout::Milliseconds(6000))
.reuse("other_notification") // <-- instead of `show()`
.unwrap();
Notification::new()
.summary("Firefox News 2")
.body("This will reuse the previous 'firefox notification'.")
.icon("firefox")
.timeout(Timeout::Milliseconds(6000))
.reuse("firefox_notification") // <-- instead of `show()`
.unwrap();
依赖项
~0.4–1.8MB
~31K SLoC