1.3.8 |
|
---|---|
1.3.7 |
|
1.3.4 |
|
#15 in #toast
46 downloads per month
31KB
683 lines
windows-toast
Show desktop notifications on Windows
Example
use std::{collections::HashMap, thread::sleep, time::Duration as Dur};
use windows_toast::{ActivationType, Crop, Duration, Toast, MSEDGE_APP_ID};
fn main() {
let handler = Toast::new(MSEDGE_APP_ID)
.set_title("Hello from Rust! 🦀")
.set_description("It works!")
.set_image("https://rustacean.net/assets/rustacean-flat-happy.png")
.set_icon("https://crates.io/assets/cargo.png", Crop::Circle)
.add_button(
"Yes!",
"https://www.rust-lang.org",
ActivationType::Protocol,
Some("https://icons.veryicon.com/png/o/object/material-design-icons/done-1.png"),
)
.add_button(
"Certainly!",
"https://www.rust-lang.org",
ActivationType::Protocol,
Some("https://icons.veryicon.com/png/o/business/simple-linear-icon-icon/cancel-44.png"),
)
.set_progress("Downloading", "Active", "0.0", "0/10")
.add_selection(vec!["Rust 1", "Rust 2", "Rust 3"], "selection")
.add_input("Message", "msg")
.on_activated(Box::new(move |args| {
println!("Activated! Args: {:?}", args);
}))
.show()
.unwrap();
let mut i = 0;
while i != 10 {
sleep(Dur::from_secs(1));
handler
.update_progress(
"Downloading",
"Active",
&format!("0.{}", i),
&format!("{}/10", i),
None,
None
)
.unwrap();
i += 2;
}
sleep(Dur::from_secs(1));
handler
.update_progress("Success", "Done", "1.0", "10/10. Bye!", None, None)
.unwrap();
sleep(Dur::from_secs(2));
handler.hide().unwrap();
}
Dependencies
~130MB
~2M SLoC