summaryrefslogtreecommitdiff
path: root/src/login/id.rs
blob: ab16a159d7f640d3eea862c165622d647b21e8ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use crate::user;

pub type Id = crate::id::Id<Login>;

// 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<user::Id> for Id {
    fn from(user: user::Id) -> Self {
        Self::from(String::from(user))
    }
}

impl PartialEq<user::Id> for Id {
    fn eq(&self, other: &user::Id) -> bool {
        self.as_str().eq(other.as_str())
    }
}

#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Login;

impl crate::id::Prefix for Login {
    fn prefix(&self) -> &'static str {
        user::id::User.prefix()
    }
}