Expand description
Marker traits to allow types to be contained as secrets.
Example: compare two values in constant time
assert!(!8u32.constant_eq(&4u32));
Example: randomize the contents of some bytes
let mut bytes = [0u64; 2];
bytes.randomize();
assert_ne!(bytes, [0, 0])
Example: zero out the contents of some bytes
let mut bytes = [1u8, 2, 3, 4];
bytes.zero();
assert_eq!(bytes, [0, 0, 0, 0]);
Example: copy bytes into a target, zeroing out the original bytes
let mut src = [4u8; 4];
let mut dst = [1u8; 4];
unsafe { src.transfer(&mut dst) };
assert_eq!(src, [0, 0, 0, 0]);
assert_eq!(dst, [4, 4, 4, 4]);
Traits
Marker trait for types who are intrepretable as a series of
contiguous bytes, where the exact size may not be known at
compile-time. Any type that implements AsContiguousBytes
must
not exhibit undefined behavior when its underlying bits are set to
any arbitrary bit pattern.
A marker trait for types whose size is known at compile time and can
be treated as raw buckets of bytes. Any type that implements Bytes
must not exhibit undefined behavior when its underlying bits are set
to any arbitrary bit pattern.
A marker trait for types that can be compared for equality bitwise in constant time.
Types that can be safely initialized by setting their memory to a random value.
Types that can be safely initialized by setting their memory to all zeroes.