#[non_exhaustive]pub struct Rng;unstable only.Expand description
(Pseudo-)Random Number Generator
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Implementations§
Source§impl Rng
 
impl Rng
Sourcepub fn new() -> Self
 
pub fn new() -> Self
Creates a new random number generator instance.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn random(&self) -> u32
 
pub fn random(&self) -> u32
Reads currently available u32 integer from RNG.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn read(&self, buffer: &mut [u8])
 
pub fn read(&self, buffer: &mut [u8])
Reads enough bytes from hardware random number generator to fill
buffer.
If any error is encountered then this function immediately returns. The contents of buf are unspecified in this case.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub unsafe fn read_into_raw(&self, ptr: *mut u8, len: usize)
 
pub unsafe fn read_into_raw(&self, ptr: *mut u8, len: usize)
Reads enough bytes from hardware random number generator to fill
buffer.
If any error is encountered then this function immediately returns. The contents of buf are unspecified in this case.
§Safety
ptr must not be null and valid for writes for len bytes.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Trait Implementations§
Source§impl RngCore for Rng
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
 
impl RngCore for Rng
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Source§fn fill_bytes(&mut self, dest: &mut [u8])
 
fn fill_bytes(&mut self, dest: &mut [u8])
dest with random data. Read moreSource§fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>
 
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>
dest entirely with random data. Read moreSource§impl RngCore for Rng
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
 
impl RngCore for Rng
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
impl Copy for Rng
Auto Trait Implementations§
impl Freeze for Rng
impl RefUnwindSafe for Rng
impl Send for Rng
impl Sync for Rng
impl Unpin for Rng
impl UnwindSafe for Rng
Blanket Implementations§
§impl<T> Any for Twhere
    T: 'static + ?Sized,
 
impl<T> Any for Twhere
    T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
    T: ?Sized,
 
impl<T> Borrow<T> for Twhere
    T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
 
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)§impl<T, U> Into<U> for Twhere
    U: From<T>,
 
impl<T, U> Into<U> for Twhere
    U: From<T>,
§impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,
 
impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,
§impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,
 
impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,
Source§impl<R> TryRngCore for Rwhere
    R: RngCore + ?Sized,
 
impl<R> TryRngCore for Rwhere
    R: RngCore + ?Sized,
Source§fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
 
fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
u32.Source§fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
 
fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
u64.Source§fn try_fill_bytes(
    &mut self,
    dst: &mut [u8],
) -> Result<(), <R as TryRngCore>::Error>
 
fn try_fill_bytes( &mut self, dst: &mut [u8], ) -> Result<(), <R as TryRngCore>::Error>
dest entirely with random data.Source§fn unwrap_err(self) -> UnwrapErr<Self>where
    Self: Sized,
 
fn unwrap_err(self) -> UnwrapErr<Self>where
    Self: Sized,
UnwrapErr wrapper.Source§fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
 
fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
UnwrapMut wrapper.