pub trait Obfuscate {
// Required method
fn obfuscate(&self) -> String;
}Available on crate feature
security only.Expand description
Trait for types that can be obfuscated for safe logging.
Implement this trait for custom types that contain sensitive data.
§Example
use allframe_core::security::Obfuscate;
struct DatabaseConfig {
host: String,
password: String,
}
impl Obfuscate for DatabaseConfig {
fn obfuscate(&self) -> String {
format!("DatabaseConfig {{ host: {}, password: *** }}", self.host)
}
}
let config = DatabaseConfig {
host: "localhost".to_string(),
password: "secret".to_string(),
};
assert_eq!(config.obfuscate(), "DatabaseConfig { host: localhost, password: *** }");