kxio 1.1.2

Provides injectable Filesystem and Network resources to make code more testable
Documentation
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)
    }
}

/// "Password for HTTP authentication");
#[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()
    }
    // pub const fn as_str(&self) -> &str {
    //     "********"
    // }
}
impl From<Password> for NetAuthPassword {
    fn from(password: Password) -> Self {
        Self(password)
    }
}
// new_type_display!(NetAuthPassword);

#[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
    }
}