pub struct Trng<'d> {
pub rng: Rng,
/* private fields */
}
Available on crate feature
unstable
only.Expand description
True Random Number Generator (TRNG) driver
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.
Fields§
§rng: Rng
The hardware random number generator instance.
Implementations§
Source§impl<'d> Trng<'d>
impl<'d> Trng<'d>
Sourcepub fn new(
rng: impl Peripheral<P = RNG>,
adc: impl Peripheral<P = ADC1> + 'd,
) -> Self
pub fn new( rng: impl Peripheral<P = RNG>, adc: impl Peripheral<P = ADC1> + 'd, ) -> Self
Trait Implementations§
Source§impl Peripheral for Trng<'_>
impl Peripheral for Trng<'_>
Source§unsafe fn clone_unchecked(&self) -> Self::P
unsafe fn clone_unchecked(&self) -> Self::P
Unsafely clone (duplicate) a peripheral singleton. Read more
Source§fn into_ref<'a>(self) -> PeripheralRef<'a, Self::P>where
Self: 'a,
fn into_ref<'a>(self) -> PeripheralRef<'a, Self::P>where
Self: 'a,
Convert a value into a
PeripheralRef
. Read moreSource§impl RngCore for Trng<'_>
Implementing RngCore trait from rand_core for Trng
structure
impl RngCore for Trng<'_>
Implementing RngCore trait from rand_core for Trng
structure
Source§fn fill_bytes(&mut self, dest: &mut [u8])
fn fill_bytes(&mut self, dest: &mut [u8])
Fill
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>
Fill
dest
entirely with random data. Read moreimpl CryptoRng for Trng<'_>
Implementing a CryptoRng marker trait that indicates that the generator is cryptographically secure.
Auto Trait Implementations§
impl<'d> Freeze for Trng<'d>
impl<'d> RefUnwindSafe for Trng<'d>
impl<'d> Send for Trng<'d>
impl<'d> Sync for Trng<'d>
impl<'d> Unpin for Trng<'d>
impl<'d> !UnwindSafe for Trng<'d>
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
Mutably borrows from an owned value. Read more
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
Upcast to an
RngCore
trait object.