Skip to main content

system_extensions/notifications/
notification.rs

1/**
2   Create a simple notification.
3
4   (Experimental: Windows Only)
5
6   A simple notification is a notification that is basic and exists for easy use and is
7   guaranteed to mainly work cross-platform.
8*/
9pub struct SimpleNotification {
10    pub(crate) title: String,
11    pub(crate) text: Vec<String>,
12    pub(crate) app_logo: String,
13    pub(crate) hero_image: String,
14    pub(crate) app_id: String,
15}
16
17impl SimpleNotification {
18    /**
19        Create a new SimpleNotification.
20    */
21    pub fn new(title: String) -> SimpleNotification {
22        SimpleNotification {
23            title,
24            text: vec![],
25            app_logo: "".to_string(),
26            hero_image: "".to_string(),
27            app_id: "".to_string()
28        }
29    }
30
31    /**
32        Set the Title.
33    */
34    pub fn set_title(mut self, title: String) -> Self{
35        self.title = title;
36        self
37    }
38
39    pub fn add_text(mut self, line: String) -> Self {
40        self.text.push(line);
41        self
42    }
43
44    pub fn set_text(mut self, text: Vec<String>) -> Self{
45        self.text = text;
46        self
47    }
48
49    /**
50        Set the app logo. (Windows Only).
51    */
52    pub fn set_app_logo(mut self, app_logo: String) -> Self {
53        self.app_logo = app_logo;
54        self
55    }
56
57    /**
58        Set the hero image. (Windows Only).
59    */
60    pub fn set_hero_image(mut self, hero_image: String) -> Self {
61        self.hero_image = hero_image;
62        self
63    }
64
65    /**
66        Set the app id. (Windows Only).
67    */
68    pub fn set_app_id(mut self, app_id: String) -> Self {
69        self.app_id = app_id;
70        self
71    }
72
73    /**
74        Display the notification.
75    */
76    pub fn display(self) {
77        crate::internal::notifications::send_simple_notification(self);
78    }
79}