Function getrandom::getrandom [−][src]
pub fn getrandom(dest: &mut [u8]) -> Result<(), Error>
Expand description
Fill dest
with random bytes from the system’s preferred random number
source.
This function returns an error on any failure, including partial reads. We
make no guarantees regarding the contents of dest
on error. If dest
is
empty, getrandom
immediately returns success, making no calls to the
underlying operating system.
Blocking is possible, at least during early boot; see module documentation.
In general, getrandom
will be fast enough for interactive usage, though
significantly slower than a user-space CSPRNG; for the latter consider
rand::thread_rng
.