pub struct Rng<'d, T: Instance> { /* private fields */ }Expand description
Random number generator. Cancellation disables its peripheral interrupt.
Implementations§
Source§impl<'d, T: Instance> Rng<'d, T>
impl<'d, T: Instance> Rng<'d, T>
Sourcepub fn new(
inner: Peri<'d, T>,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
) -> Self
pub fn new( inner: Peri<'d, T>, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, ) -> Self
Enable the generator. This constructor does not wait for entropy.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Restart the generator and discard its first ready word on the next read.
This does not wait for clock or seed faults to disappear.
Sourcepub fn recover_seed_error(&mut self)
pub fn recover_seed_error(&mut self)
Restart after a seed failure. Subsequent reads report persistent errors.
Sourcepub fn try_next_u32(&mut self) -> Result<Option<u32>, Error>
pub fn try_next_u32(&mut self) -> Result<Option<u32>, Error>
Read one available word without waiting. None means more entropy is needed.
Sourcepub fn blocking_next_u32(&mut self) -> Result<u32, Error>
pub fn blocking_next_u32(&mut self) -> Result<u32, Error>
Wait for a random word, reporting hardware errors instead of retrying them.
Sourcepub async fn async_next_u32(&mut self) -> Result<u32, Error>
pub async fn async_next_u32(&mut self) -> Result<u32, Error>
Wait for a word using the RNG interrupt. Errors take priority over data.
Sourcepub async fn async_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>
pub async fn async_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>
Fill bytes, returning a hardware error if generation fails.
On failure or cancellation an already filled prefix is retained.
Trait Implementations§
impl<'d, T: Instance> CryptoRng for Rng<'d, T>
Auto Trait Implementations§
impl<'d, T> !UnwindSafe for Rng<'d, T>
impl<'d, T> Freeze for Rng<'d, T>where
T: Freeze,
impl<'d, T> RefUnwindSafe for Rng<'d, T>where
T: RefUnwindSafe,
impl<'d, T> Send for Rng<'d, T>
impl<'d, T> Sync for Rng<'d, T>where
T: Sync,
impl<'d, T> Unpin for Rng<'d, T>where
T: Unpin,
impl<'d, T> UnsafeUnpin for Rng<'d, T>where
T: UnsafeUnpin,
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.