znotify/
entity.rs

1use std::fmt;
2use serde::{Deserialize, Serialize};
3use std::time::Duration;
4
5#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
6pub enum Priority {
7    #[serde(rename = "high")]
8    High,
9
10    #[serde(rename = "normal")]
11    Normal,
12
13    #[serde(rename = "low")]
14    Low,
15}
16
17impl ToString for Priority {
18    fn to_string(&self) -> String {
19        match self {
20            Priority::High => "high",
21            Priority::Normal => "normal",
22            Priority::Low => "low",
23        }
24            .to_string()
25    }
26}
27
28#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
29pub enum Channel {
30    #[serde(rename = "WebSocket")]
31    WebSocket,
32
33    #[serde(rename = "FCM")]
34    FCM,
35
36    #[serde(rename = "WebPush")]
37    WebPush,
38
39    #[serde(rename = "WNS")]
40    WNS,
41
42    #[serde(rename = "Telegram")]
43    Telegram,
44}
45
46impl ToString for Channel {
47    fn to_string(&self) -> String {
48        match self {
49            Channel::WebSocket => "WebSocket",
50            Channel::FCM => "FCM",
51            Channel::WebPush => "WebPush",
52            Channel::WNS => "WNS",
53            Channel::Telegram => "Telegram",
54        }
55            .to_string()
56    }
57}
58
59impl Default for Priority {
60    fn default() -> Self {
61        Priority::Normal
62    }
63}
64
65#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
66pub struct Message {
67    pub id: String,
68    pub title: String,
69    pub content: String,
70    pub long: String,
71    pub created_at: String,
72    pub priority: Priority,
73}
74
75#[derive(Debug)]
76pub struct MessageOptions {
77    pub content: String,
78    pub title: Option<String>,
79    pub long: Option<String>,
80    pub priority: Option<Priority>,
81}
82
83impl Default for MessageOptions {
84    fn default() -> Self {
85        Self {
86            content: String::new(),
87            title: None,
88            long: None,
89            priority: Some(Priority::default()),
90        }
91    }
92}
93
94#[derive(Debug, Serialize, Deserialize)]
95pub(crate) struct ClientResponse<T> {
96    pub(crate) code: i32,
97    pub(crate) body: T,
98}