Skip to main content

SysRng

Struct SysRng 

Source
pub struct SysRng(/* private fields */);
Expand description

A cryptographically secure random number generator.

Implementations§

Source§

impl SysRng

Source

pub fn new() -> Self

Trait Implementations§

Source§

impl Clone for SysRng

Source§

fn clone(&self) -> SysRng

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SysRng

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SysRng

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl RngCore for SysRng

Source§

fn next_u32(&mut self) -> u32

Return the next random u32. Read more
Source§

fn next_u64(&mut self) -> u64

Return the next random u64. Read more
Source§

fn fill_bytes(&mut self, dest: &mut [u8])

Fill dest with random data. Read more
Source§

fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>

Fill dest entirely with random data. Read more
Source§

impl CryptoRng for SysRng

ring::rand::SystemRandom is a cryptographically secure PRG

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<F, T, U> Apply<F, U> for T
where F: FnOnce(T) -> U,

Source§

fn apply(self, f: F) -> U

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CryptoRngCore for T
where T: CryptoRng + RngCore,

Source§

fn as_rngcore(&mut self) -> &mut dyn RngCore

Upcast to an RngCore trait object.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<R> RngExt for R
where R: RngCore,

Source§

fn gen_bytes<const N: usize>(&mut self) -> [u8; N]

Source§

fn gen_u32(&mut self) -> u32

Source§

fn gen_u64(&mut self) -> u64

Source§

fn gen_u8(&mut self) -> u8

Source§

fn gen_u16(&mut self) -> u16

Source§

fn gen_u128(&mut self) -> u128

Source§

fn gen_bool(&mut self, p: f32) -> bool

Generate true with probability p
Source§

fn gen_boolean(&mut self) -> bool

Flip a coin. Generate true with probability 0.5
Source§

fn gen_f32(&mut self) -> f32

Generates an f32 uniformly distributed in [0, 1).
Source§

fn gen_f64(&mut self) -> f64

Generates an f64 uniformly distributed in [0, 1).
Source§

fn gen_range_i32(&mut self, range: Range<i32>) -> i32

Generates an i32 in [range.start, range.end). Has slight modulo bias for large ranges. See fastmap32.
Source§

fn gen_range_u32(&mut self, range: Range<u32>) -> u32

Generates a u32 in [range.start, range.end). Has slight modulo bias for large ranges. See fastmap32.
Source§

fn gen_range_u64(&mut self, range: Range<u64>) -> u64

Generates a u32 in [range.start, range.end). Has slight modulo bias for large ranges. See fastmap64.
Source§

fn gen_range_usize(&mut self, range: Range<usize>) -> usize

Generates a usize in [range.start, range.end). Has slight modulo bias for large ranges. See fastmap64.
Source§

fn gen_alphanum_bytes<const N: usize>(&mut self) -> [u8; N]

Generate N (nearly uniformly random) alphanumeric (0-9, A-Z, a-z) bytes.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<R> Crng for R
where R: RngCore + CryptoRng,