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.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/user/id.rs b/src/user/id.rs
index 3ad8d16..ceb310a 100644
--- a/src/user/id.rs
+++ b/src/user/id.rs
@@ -1,7 +1,24 @@
+use crate::login;
+
// Stable identifier for a User. Prefixed with `U`. Users created before March, 2025 may have an `L`
// prefix, instead.
pub type Id = crate::id::Id<User>;
+// Login IDs and user IDs are typewise-distinct as they identify things in different namespaces, but
+// in practice a login and its associated user _must_ have IDs that encode to the same value. The
+// two ID types are made interconvertible (via `From`) for this purpose.
+impl From<login::Id> for Id {
+ fn from(login: login::Id) -> Self {
+ Self::from(String::from(login))
+ }
+}
+
+impl PartialEq<login::Id> for Id {
+ fn eq(&self, other: &login::Id) -> bool {
+ self.as_str().eq(other.as_str())
+ }
+}
+
#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct User;