pub struct SysRng;Available on crate feature
sys_rng only.Expand description
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 Copy for SysRng
impl TryCryptoRng for SysRng
Auto Trait Implementations§
impl Freeze for SysRng
impl RefUnwindSafe for SysRng
impl Send for SysRng
impl Sync for SysRng
impl Unpin for SysRng
impl UnwindSafe for SysRng
Blanket Implementations§
Source§impl<R> TryRngCore for Rwhere
R: TryRng,
impl<R> TryRngCore for Rwhere
R: TryRng,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more