use std::{
cmp::{Ordering, PartialOrd},
fmt::{self, Debug, Display},
};
use crate::{Password, Username};
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Credentials {
pub username: Username,
pub password: Password,
}
impl PartialOrd for Credentials {
fn partial_cmp(&self, other: &Credentials) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for Credentials {
fn cmp(&self, other: &Credentials) -> Ordering {
self.username.cmp(&other.username)
}
}
impl Display for Credentials {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}:{}", self.username, self.password)
}
}