#toast #notifications #notify #windows

winrt-toast

A toast notification library for Windows 10 and 11

2 releases

0.1.1 Aug 14, 2022
0.1.0 Aug 13, 2022

#188 in Windows APIs

Download history 366/week @ 2024-11-16 420/week @ 2024-11-23 726/week @ 2024-11-30 564/week @ 2024-12-07 418/week @ 2024-12-14 12/week @ 2024-12-21 12/week @ 2024-12-28 213/week @ 2025-01-04 567/week @ 2025-01-11 463/week @ 2025-01-18 397/week @ 2025-01-25 450/week @ 2025-02-01 344/week @ 2025-02-08 236/week @ 2025-02-15 303/week @ 2025-02-22 335/week @ 2025-03-01

1,295 downloads per month

MIT license

36KB
658 lines

winrt-toast

A mostly usable binding to the Windows ToastNotification API.

Example

use winrt_toast::{Toast, Text, Header, ToastManager};
use winrt_toast::content::text::TextPlacement;

let manager = ToastManager::new(crate::AUM_ID);

let mut toast = Toast::new();
toast
    .text1("Title")
    .text2(Text::new("Body"))
    .text3(
        Text::new("Via SMS")
            .with_placement(TextPlacement::Attribution)
    );

manager.show(&toast).expect("Failed to show toast");

// Or you may add callbacks
manager.show_with_callbacks(
    &toast, None, None,
    Some(Box::new(move |e| {
        // This will be called if Windows fails to show the toast.
        eprintln!("Failed to show toast: {:?}", e);
    }))
).expect("Failed to show toast");

To-Do Features

  • Button style and tooltips in actions
  • Better callbacks
  • Sound
  • Adaptive contents and data binding
  • Groups and sub-groups

lib.rs:

A mostly usable binding to the Windows ToastNotification API.

Example

use winrt_toast::{Toast, Text, Header, ToastManager};
use winrt_toast::content::text::TextPlacement;

let manager = ToastManager::new("YourCompany.YourApp");

let mut toast = Toast::new();
toast
    .text1("Title")
    .text2(Text::new("Body"))
    .text3(
        Text::new("Via SMS")
            .with_placement(TextPlacement::Attribution)
    );

manager.show(&toast).expect("Failed to show toast");

// Or you may add callbacks
manager.show_with_callbacks(
    &toast, None, None,
    Some(Box::new(move |e| {
        // This will be called if Windows fails to show the toast.
        eprintln!("Failed to show toast: {:?}", e);
    }))
).expect("Failed to show toast");

Dependencies

~124MB
~2M SLoC