#[non_exhaustive]pub struct Trng { /* private fields */ }unstable only.Expand description
True Random Number Generator (TRNG)
The Trng struct represents a true random number generator that combines
the randomness from the hardware RNG and an ADC. This struct provides
methods to generate random numbers and fill buffers with random bytes.
Due to pulling the entropy source from the ADC, it uses the associated
registers, so to use TRNG we need to “occupy” the ADC peripheral.
§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 Trng
 
impl Trng
Sourcepub fn try_new() -> Result<Self, TrngError>
 
pub fn try_new() -> Result<Self, TrngError>
Attempts to create a new True Random Number Generator (TRNG) instance.
This function returns a new Trng instance on success, or an error if the
TrngSource is not active.
§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
Returns a new, random u32 integer.
§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 Trng
§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 Trng
§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 Trng
§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 Trng
§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 CryptoRng for Trng
§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 CryptoRng for Trng
§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.
Auto Trait Implementations§
impl Freeze for Trng
impl RefUnwindSafe for Trng
impl Send for Trng
impl Sync for Trng
impl Unpin for Trng
impl UnwindSafe for Trng
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)Source§impl<T> CryptoRngCore for T
 
impl<T> CryptoRngCore for T
Source§fn as_rngcore(&mut self) -> &mut dyn RngCore
 
fn as_rngcore(&mut self) -> &mut dyn RngCore
RngCore trait object.§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.