Struct SysRng
pub struct SysRng;
A TryRng interface over the system's preferred random number source
This is a zero-sized struct. It can be freely constructed with just SysRng.
This struct is also available as rand::rngs::SysRng when using rand.
Usage example
SysRng implements [TryRng]:
use getrandom::{rand_core::TryRng, SysRng};
let mut key = [0u8; 32];
SysRng.try_fill_bytes(&mut key).unwrap();
Using it as an Rng is possible using UnwrapErr:
use getrandom::rand_core::{Rng, UnwrapErr};
use getrandom::SysRng;
let mut rng = UnwrapErr(SysRng);
let random_u64 = rng.next_u64();
Trait Implementations
impl Clone for SysRng
fn clone(&self) -> Self
impl Copy for SysRng
impl Debug for SysRng
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for SysRng
fn default() -> Self
impl TryCryptoRng for SysRng
impl TryRng for SysRng
type Error = Error;fn try_next_u32(&mut self) -> Result<u32, Error>fn try_next_u64(&mut self) -> Result<u64, Error>fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>