pub struct SysRng;Available on crate feature
getrandom only.Expand description
A TryRngCore 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 TryRngCore:
use getrandom::{rand_core::TryRngCore, SysRng};
let mut key = [0u8; 32];
SysRng.try_fill_bytes(&mut key).unwrap();Using it as an RngCore is possible using TryRngCore::unwrap_err:
use getrandom::rand_core::{TryRngCore, RngCore};
use getrandom::SysRng;
let mut rng = SysRng.unwrap_err();
let random_u64 = rng.next_u64();Trait Implementations§
Source§impl TryRngCore for SysRng
impl TryRngCore for SysRng
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<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