Crates.io | windows-toast |
lib.rs | windows-toast |
version | 1.3.8 |
source | src |
created_at | 2023-01-29 00:29:42.197201 |
updated_at | 2023-02-11 14:02:23.056776 |
description | Show desktop notifications on Windows |
homepage | |
repository | |
max_upload_size | |
id | 770661 |
size | 37,054 |
Show desktop notifications on Windows
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();
}