#[derive(SecureSanitizeOnDrop)]
{
// Attributes available to this derive:
#[sanitization]
}
Expand description
Derive Drop by invoking the complete SecureSanitize implementation.
The generated destructor requires Self: DropSafeSanitize + Unpin.
#[derive(SecureSanitize)] provides DropSafeSanitize automatically for
its generated field-wise sanitizer. A reviewed manual aggregate sanitizer
must implement DropSafeSanitize explicitly; this preserves external
storage, ordering, and platform cleanup while making recursive
self-destruction an explicit contract violation.
Enums are rejected even when they have a manual SecureSanitize
implementation. Calling that implementation at final drop cannot clear
inactive bytes retained by ordinary variant transitions. Use a stable-layout
struct state machine, or a reviewed manual Drop implementation together
with sanitization::secure_replace before every enum transition.
§Generics
For structs with type parameters that hold sanitizable data, the parameter
must carry SecureSanitize + Unpin bounds at the type declaration:
use sanitization::SecureSanitize;
#[derive(SecureSanitize, SecureSanitizeOnDrop)]
struct Wrapper<T: SecureSanitize + Unpin> {
inner: T,
}This is a Rust Drop restriction: the generated Drop impl cannot add a
stricter T: SecureSanitize + Unpin bounds than the struct declaration
itself.