Add ID type for notifications

This commit is contained in:
D. Scott Boggs 2023-01-09 07:53:35 -05:00 committed by Scott Boggs
parent c5f199b460
commit f188c20250
1 changed files with 12 additions and 1 deletions

View File

@ -9,7 +9,7 @@ use time::{serde::iso8601, OffsetDateTime};
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
pub struct Notification {
/// The notification ID.
pub id: String,
pub id: NotificationId,
/// The type of notification.
#[serde(rename = "type")]
pub notification_type: NotificationType,
@ -22,6 +22,17 @@ pub struct Notification {
pub status: Option<Status>,
}
/// Wrapper type for a notification ID string
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(transparent)]
pub struct NotificationId(String);
impl AsRef<str> for NotificationId {
fn as_ref(&self) -> &str {
&self.0
}
}
/// The type of notification.
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]