pub trait ZeroizeOnDrop { }Expand description
Marks a type that erases its contents when dropped.
Implementors must provide their own Drop implementation that calls
Zeroize::zeroize. This marker generates no behavior and does not enforce
that requirement. It expresses a policy for types that know they hold
secrets, rather than for general-purpose storage types.
use tc_zeroize::{Zeroize, ZeroizeOnDrop};
struct Secret([u8; 32]);
impl Zeroize for Secret {
fn zeroize(&mut self) {
self.0.zeroize();
}
}
impl Drop for Secret {
fn drop(&mut self) {
self.zeroize();
}
}
impl ZeroizeOnDrop for Secret {}
let _secret = Secret([7; 32]);Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".