Skip to main content

SecureSanitize

Derive Macro SecureSanitize 

Source
#[derive(SecureSanitize)]
{
    // Attributes available to this derive:
    #[sanitization]
}
Expand description

Derive sanitization::SecureSanitize for structs.

Every non-skipped field must implement SecureSanitize. Skipped fields require a non-empty audit reason:

ⓘ
#[sanitization(skip, reason = "public algorithm identifier")]

Enums are rejected because generated safe code can only reach the active variant and therefore cannot clear bytes retained from a previously active, larger variant. Model secret state with a struct plus an explicit public discriminator, or implement a reviewed transition that calls sanitization::secure_replace before changing representation.

The derive also implements sanitization::DropSafeSanitize because its sanitizer is generated field-wise and cannot replace or destroy Self.