pub struct Privacy;
impl Default for Privacy {
fn default() -> Self {
Self::new()
}
}
impl Privacy {
pub fn new() -> Self {
Privacy
}
pub fn desensitize(&self, s: &str) -> String {
if s.is_empty() {
"<empty>".to_string()
} else if s.len() <= 4 {
s.to_string()
} else {
format!("{}***", &s[..4])
}
}
}