#[non_exhaustive]pub struct Rng;Expand description
Implementations§
Source§impl Rng
impl Rng
Sourcepub fn random(&self) -> u32
pub fn random(&self) -> u32
Reads currently available u32 integer from RNG.
§Example
use esp_hal::rng::Rng;
let rng = Rng::new();
let random_number = rng.random();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.
§Example
use esp_hal::rng::Rng;
let rng = Rng::new();
let mut rng_values = [0; 10];
rng.read(&mut rng_values);Sourcepub unsafe fn read_into_raw(&self, ptr: *mut u8, len: usize)
Available on crate feature unstable only.
pub unsafe fn read_into_raw(&self, ptr: *mut u8, len: usize)
unstable only.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
Available on crate feature unstable only.Compatibility with rand_core 0.6. Documentation can be found at
https://docs.rs/rand_core/0.6.4/rand_core/trait.RngCore.html.
impl RngCore for Rng
unstable only.Compatibility with rand_core 0.6. Documentation can be found at
https://docs.rs/rand_core/0.6.4/rand_core/trait.RngCore.html.
§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
Available on crate feature unstable only.Compatibility with rand_core 0.9. Documentation can be found at
https://docs.rs/rand_core/0.9.5/rand_core/trait.RngCore.html.
impl RngCore for Rng
unstable only.Compatibility with rand_core 0.9. Documentation can be found at
https://docs.rs/rand_core/0.9.5/rand_core/trait.RngCore.html.
§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§impl TryRng for Rng
Available on crate feature unstable only.Compatibility with rand_core 0.10
impl TryRng for Rng
unstable only.Compatibility with rand_core 0.10
§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 try_next_u32(&mut self) -> Result<u32, Self::Error>
fn try_next_u32(&mut self) -> Result<u32, Self::Error>
u32.Source§fn try_next_u64(&mut self) -> Result<u64, Self::Error>
fn try_next_u64(&mut self) -> Result<u64, Self::Error>
u64.Source§fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Self::Error>
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Self::Error>
dst entirely with random data.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 UnsafeUnpin for Rng
impl UnwindSafe for Rng
Blanket Implementations§
Source§impl<R> TryRngCore for Rwhere
R: TryRng,
impl<R> TryRngCore for Rwhere
R: TryRng,
§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.