summaryrefslogtreecommitdiff
path: root/src/push/id.rs
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2025-07-24 22:32:27 -0400
committerOwen Jacobson <owen@grimoire.ca>2025-07-24 22:32:27 -0400
commitb63380b251d04dd92f06aa5bbc22a72ca3e4bf8e (patch)
tree3956ec457131ce049fd91f2f53309bc0620fffe2 /src/push/id.rs
parent2e42057694851b82574e0a406ded429fb95a07fa (diff)
wip: 83B78D40-D7CB-4419-9FE7-E7D858909443
Diffstat (limited to 'src/push/id.rs')
-rw-r--r--src/push/id.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/push/id.rs b/src/push/id.rs
new file mode 100644
index 0000000..b28d6ab
--- /dev/null
+++ b/src/push/id.rs
@@ -0,0 +1,27 @@
+use std::fmt;
+
+use crate::id::Id as BaseId;
+
+// Stable identifier for a push subscription. Prefixed with `S`.
+#[derive(Clone, Debug, Eq, Hash, PartialEq, sqlx::Type, serde::Deserialize, serde::Serialize)]
+#[sqlx(transparent)]
+#[serde(transparent)]
+pub struct Id(BaseId);
+
+impl From<BaseId> for Id {
+ fn from(id: BaseId) -> Self {
+ Self(id)
+ }
+}
+
+impl Id {
+ pub fn generate() -> Self {
+ BaseId::generate("S")
+ }
+}
+
+impl fmt::Display for Id {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ self.0.fmt(f)
+ }
+}