pub unsafe trait FillBytes {
// Provided methods
fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ { ... }
fn fill_bytes(&mut self, value: u8) { ... }
fn fill_random(&mut self, rng: impl RngCore) { ... }
fn fill_with<R>(&mut self, f: impl FnOnce(&mut [u8]) -> R) -> R { ... }
fn canonicalize_bytes(&mut self) { ... }
}
Expand description
Access a value as a mutable slice of bytes.
§Safety
This trait must only be implemented for types which can accept any pattern of bits as a legitimate value.
Provided Methods§
Sourcefn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
Access the value as a mutable slice of bytes.
Sourcefn fill_bytes(&mut self, value: u8)
fn fill_bytes(&mut self, value: u8)
Fill the value with repeated bytes.
Sourcefn fill_random(&mut self, rng: impl RngCore)
fn fill_random(&mut self, rng: impl RngCore)
Fill the value with random bytes.
Sourcefn fill_with<R>(&mut self, f: impl FnOnce(&mut [u8]) -> R) -> R
fn fill_with<R>(&mut self, f: impl FnOnce(&mut [u8]) -> R) -> R
Fill the value using a closure.
Sourcefn canonicalize_bytes(&mut self)
fn canonicalize_bytes(&mut self)
After filling the bytes, try to ensure consistency across platforms.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.