From f4ef3c27ab08005ac6a9984926ecfdaceade1244 Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Mon, 9 Jan 2023 07:53:44 -0500 Subject: [PATCH] Add ID type for pushes --- entities/src/push.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/entities/src/push.rs b/entities/src/push.rs index c86f899..b2a1877 100644 --- a/entities/src/push.rs +++ b/entities/src/push.rs @@ -17,7 +17,7 @@ pub struct Alerts { #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct Subscription { /// The `id` of the subscription - pub id: String, + pub id: SubscriptionId, /// The endpoint of the subscription pub endpoint: String, /// The server key of the subscription @@ -26,6 +26,17 @@ pub struct Subscription { pub alerts: Option, } +/// Wrapper type for a subscription ID string +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[serde(transparent)] +pub struct SubscriptionId(String); + +impl AsRef for SubscriptionId { + fn as_ref(&self) -> &str { + &self.0 + } +} + pub mod add_subscription { use serde::Serialize;