#[derive(SecureSerialize)]
{
// Attributes available to this derive:
#[redact]
#[secure_serialize]
}
Expand description
Derives SecureSerialize for a struct.
Fields marked with #[redact] or #[redact(with = "...")] will be redacted when serialized.
§Field attributes
#[redact]— Redact with default"<redacted>"#[redact(with = "***")]— Redact with custom string"***"
§Struct attributes
#[secure_serialize(debug)]— Generatefmt::Debugwith redacted fields (declaration order).#[secure_serialize(display)]— Generatefmt::Displayas compact redacted JSON.#[secure_serialize(debug, display)]— Both.
§Example
ⓘ
#[derive(SecureSerialize, Deserialize)]
#[secure_serialize(debug, display)]
struct Config {
pub host: String,
#[redact]
pub api_key: String,
#[redact(with = "***")]
pub password: String,
}