|
pub trait DefaultIsZeroes: Copy + Default + Sized {} |
What is recommended approach to implement Zeroize for non-copy-types? Consider some library has non-copy type:
// somelib.rs
#[derive(Clone)]
pub struct SecretKey([u8; 32]);
And in user code we have wrapper around that which we would like to zeroize on drop:
// main.rs
#[derive(Clone)]
struct MyKey(SecretKey);
One approach would be to implement Default for MyKey and add impl DefaultIsZeroes for MyKey {} so MyKey will implement Zeroize, but it is not possible because of Copy constraint on DefaultIsZeroes
utils/zeroize/src/lib.rs
Line 283 in 216d2b8
What is recommended approach to implement
Zeroizefor non-copy-types? Consider some library has non-copy type:And in user code we have wrapper around that which we would like to zeroize on drop:
One approach would be to implement
DefaultforMyKeyand addimpl DefaultIsZeroes for MyKey {}soMyKeywill implementZeroize, but it is not possible because ofCopyconstraint onDefaultIsZeroes