credent_model/
credentials.rs1use std::{
2    cmp::{Ordering, PartialOrd},
3    fmt::{self, Debug, Display},
4};
5
6use crate::{Password, Username};
7
8#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
10#[derive(Clone, Debug, PartialEq, Eq)]
11pub struct Credentials {
12    pub username: Username,
14    pub password: Password,
16}
17
18impl PartialOrd for Credentials {
19    fn partial_cmp(&self, other: &Credentials) -> Option<Ordering> {
20        Some(self.cmp(other))
21    }
22}
23
24impl Ord for Credentials {
25    fn cmp(&self, other: &Credentials) -> Ordering {
26        self.username.cmp(&other.username)
27    }
28}
29
30impl Display for Credentials {
31    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
32        write!(f, "{}:{}", self.username, self.password)
33    }
34}