pub unsafe trait Zeroable: AsContiguousBytes {
    fn zero(&mut self) { ... }
unsafe fn transfer(&mut self, other: &mut Self) { ... } }
Expand description

Types that can be safely initialized by setting their memory to all zeroes.

The trait is marked unsafe in order to restrict implementors to types that can safely have their underlying memory set to all zeroes.

Safety

This trait allows for overwriting a type’s memory with zeros. If it is not legal to represent your type as zero bits, then your type may not implement this trait.

Provided methods

Zeroes out the underlying storage.

We use sodium::memzero rather than ptr::write_bytes because the libsodium version is more resilient against being optimized out by a smart compiler.

Copies all bytes from self into other before zeroing out self.

Safety

other must be at least as large as self and the two references must not overlap.

Implementors