summaryrefslogtreecommitdiff
path: root/src/user/id.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/id.rs')
-rw-r--r--src/user/id.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/user/id.rs b/src/user/id.rs
new file mode 100644
index 0000000..bc14c1f
--- /dev/null
+++ b/src/user/id.rs
@@ -0,0 +1,25 @@
+use crate::id::Id as BaseId;
+
+// Stable identifier for a User. Prefixed with `U`. Users created before March, 2025 may have an `L`
+// prefix, instead.
+#[derive(Clone, Debug, Eq, PartialEq, sqlx::Type, serde::Serialize)]
+#[sqlx(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("U")
+ }
+}
+
+impl std::fmt::Display for Id {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ self.0.fmt(f)
+ }
+}