Obfuscate

Derive Macro Obfuscate 

Source
#[derive(Obfuscate)]
{
    // Attributes available to this derive:
    #[sensitive]
    #[obfuscate]
}
Available on crate feature security only.
Expand description

Re-export Obfuscate derive macro for safe logging Derive macro for automatic Obfuscate implementation

Generates the Obfuscate trait implementation that safely logs struct fields, obfuscating those marked with #[sensitive].

§Example

use allframe_macros::Obfuscate;

#[derive(Obfuscate)]
struct DatabaseConfig {
    host: String,
    port: u16,
    #[sensitive]
    password: String,
    #[sensitive]
    api_key: String,
}

let config = DatabaseConfig {
    host: "localhost".to_string(),
    port: 5432,
    password: "secret".to_string(),
    api_key: "sk_live_abc123".to_string(),
};

// Output: "DatabaseConfig { host: "localhost", port: 5432, password: ***, api_key: *** }"
println!("{}", config.obfuscate());

§Attributes

  • #[sensitive] - Mark field as sensitive, will be displayed as ***
  • #[obfuscate(with = "function_name")] - Use custom function to obfuscate