#[cfg(test)]
mod tests;
use serde::Deserialize;
#[derive(Clone, PartialEq, Eq, Deserialize)]
#[serde(transparent)]
pub struct SecretString(String);
impl SecretString {
pub fn new(value: impl Into<String>) -> Self {
Self(value.into())
}
pub fn expose_secret(&self) -> &str {
&self.0
}
}
impl std::fmt::Debug for SecretString {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("SecretString([redacted])")
}
}
impl<T: Into<String>> From<T> for SecretString {
fn from(value: T) -> Self {
Self::new(value)
}
}