pub trait CryptoRng {
// Required method
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<()>;
}Expand description
Marker and interface for cryptographically secure pseudorandom number generators (CSPRNGs).
Implementors MUST guarantee cryptographic unpredictability (e.g., backed by OS CSPRNG such as
getrandom). Non-cryptographic PRNGs MUST NOT implement this trait in production code.
Required Methods§
Sourcefn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<()>
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<()>
Fills dest with cryptographically secure random bytes.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".