From 2420f1e75d54a5f209b0267715f078a369d81eb1 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Sun, 23 Mar 2025 15:58:33 -0400 Subject: Rename the `login` module to `user`. --- src/user/id.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/user/id.rs (limited to 'src/user/id.rs') diff --git a/src/user/id.rs b/src/user/id.rs new file mode 100644 index 0000000..9455deb --- /dev/null +++ b/src/user/id.rs @@ -0,0 +1,24 @@ +use crate::id::Id as BaseId; + +// Stable identifier for a User. Prefixed with `L`. +#[derive(Clone, Debug, Eq, PartialEq, sqlx::Type, serde::Serialize)] +#[sqlx(transparent)] +pub struct Id(BaseId); + +impl From for Id { + fn from(id: BaseId) -> Self { + Self(id) + } +} + +impl Id { + pub fn generate() -> Self { + BaseId::generate("L") + } +} + +impl std::fmt::Display for Id { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.0.fmt(f) + } +} -- cgit v1.2.3 From f6191926ba94b8a1b303bca7c6996dce67781290 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Sun, 23 Mar 2025 16:18:24 -0400 Subject: Change the prefix for newly-generated user IDs to `U`, for `User`. --- src/user/id.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/user/id.rs') diff --git a/src/user/id.rs b/src/user/id.rs index 9455deb..bc14c1f 100644 --- a/src/user/id.rs +++ b/src/user/id.rs @@ -1,6 +1,7 @@ use crate::id::Id as BaseId; -// Stable identifier for a User. Prefixed with `L`. +// 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); @@ -13,7 +14,7 @@ impl From for Id { impl Id { pub fn generate() -> Self { - BaseId::generate("L") + BaseId::generate("U") } } -- cgit v1.2.3