From f188c202508ccd05f6c5e18a69d0895444a11a74 Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Mon, 9 Jan 2023 07:53:35 -0500 Subject: [PATCH] Add ID type for notifications --- entities/src/notification.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/entities/src/notification.rs b/entities/src/notification.rs index cd930fc..df538ff 100644 --- a/entities/src/notification.rs +++ b/entities/src/notification.rs @@ -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, } +/// Wrapper type for a notification ID string +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[serde(transparent)] +pub struct NotificationId(String); + +impl AsRef 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")]