firebae_cm/notification/
notification.rs1use crate::Color;
2
3#[derive(serde::Serialize, Debug, Clone)]
6#[serde(rename_all = "snake_case")]
7pub enum NotificationPriority {
8 PriorityUnspecified,
9 PriorityMin,
10 PriorityLow,
11 PriorityDefault,
12 PriorityHigh,
13 PriorityMax,
14}
15
16#[derive(serde::Serialize, Debug, Clone)]
19#[serde(rename_all = "snake_case")]
20pub enum Visibility {
21 VisibilityUnspecified,
22 Private,
23 Public,
24 Secret,
25}
26
27#[derive(serde::Serialize, Debug, Default, Clone)]
31pub struct LightSettings {
32 #[serde(skip_serializing_if = "Option::is_none")]
33 color: Option<Color>,
34 #[serde(skip_serializing_if = "Option::is_none")]
35 light_on_duration: Option<String>,
36 #[serde(skip_serializing_if = "Option::is_none")]
37 light_off_duration: Option<String>,
38}
39
40impl LightSettings {
41 pub fn new() -> Self {
42 Default::default()
43 }
44
45 pub fn color(&mut self, color: Color) -> &mut Self {
46 self.color = Some(color);
47 self
48 }
49
50 pub fn light_on_duration(&mut self, seconds: usize) -> &mut Self {
51 self.light_on_duration = Some(format!("{}s", seconds));
52 self
53 }
54
55 pub fn light_off_duration(&mut self, seconds: usize) -> &mut Self {
56 self.light_off_duration = Some(format!("{}s", seconds));
57 self
58 }
59}
60
61#[derive(serde::Serialize, Debug, Clone, Default)]
72pub struct Notification {
73 #[serde(skip_serializing_if = "Option::is_none")]
74 pub title: Option<String>,
75 #[serde(skip_serializing_if = "Option::is_none")]
76 pub body: Option<String>,
77 #[serde(skip_serializing_if = "Option::is_none")]
78 pub image: Option<String>,
79}
80
81impl Notification {
82 pub fn new() -> Self {
84 Default::default()
85 }
86
87 pub fn with_title(mut self, title: impl Into<String>) -> Self {
92 self.title = Some(title.into());
93 self
94 }
95
96 pub fn with_body(mut self, body: impl Into<String>) -> Self {
101 self.body = Some(body.into());
102 self
103 }
104
105 pub fn with_image(mut self, image: impl Into<String>) -> Self {
110 self.image = Some(image.into());
111 self
112 }
113}