use std::fmt::{Display, Formatter};
#[derive(Debug, Clone)]
pub struct Password(secrecy::SecretString);
impl Password {
pub fn new(password: String) -> Self {
Self(secrecy::SecretString::new(password))
}
pub fn expose_password(&self) -> &str {
secrecy::ExposeSecret::expose_secret(&self.0)
}
}
#[derive(Debug, Clone)]
pub struct NetAuthUsername(String);
impl NetAuthUsername {
pub const fn new(username: String) -> Self {
Self(username)
}
pub fn as_str(&self) -> &str {
&self.0
}
}
impl Display for NetAuthUsername {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
#[derive(Debug, Clone)]
pub struct NetAuthPassword(Password);
impl NetAuthPassword {
pub fn new(password: String) -> Self {
Self(Password::new(password))
}
pub fn expose_password(&self) -> &str {
self.0.expose_password()
}
}
impl From<Password> for NetAuthPassword {
fn from(password: Password) -> Self {
Self(password)
}
}
#[derive(Debug, Clone)]
pub struct NetAuth {
username: NetAuthUsername,
password: NetAuthPassword,
}
impl NetAuth {
pub const fn new(username: NetAuthUsername, password: NetAuthPassword) -> Self {
Self { username, password }
}
pub const fn username(&self) -> &NetAuthUsername {
&self.username
}
pub const fn password(&self) -> &NetAuthPassword {
&self.password
}
}