windows-toast

Crates.iowindows-toast
lib.rswindows-toast
version1.3.8
sourcesrc
created_at2023-01-29 00:29:42.197201
updated_at2023-02-11 14:02:23.056776
descriptionShow desktop notifications on Windows
homepage
repository
max_upload_size
id770661
size37,054
Dmitriy (gpoddmi)

documentation

https://docs.rs/windows-toast/

README

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();
}

Commit count: 0

cargo fmt