pub struct Rng { /* private fields */ }
Expand description

Random Number Generator

It should be noted that there are certain pre-conditions which must be met in order for the RNG to produce true random numbers. The hardware RNG produces true random numbers under any of the following conditions:

  • RF subsystem is enabled (i.e. Wi-Fi or Bluetooth are enabled).
  • An internal entropy source has been enabled by calling bootloader_random_enable() and not yet disabled by calling bootloader_random_disable().
  • While the ESP-IDF Second stage bootloader is running. This is because the default ESP-IDF bootloader implementation calls bootloader_random_enable() when the bootloader starts, and bootloader_random_disable() before executing the app.

When any of these conditions are true, samples of physical noise are continuously mixed into the internal hardware RNG state to provide entropy. If none of the above conditions are true, the output of the RNG should be considered pseudo-random only.

For more information, please refer to the ESP-IDF documentation: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/random.html

Implementations

Create a new random number generator instance

Reads currently available u32 integer from RNG

Return the raw interface to the underlying Rng instance

Trait Implementations

Formats the value using the given formatter. Read more

Error type

Reads enough bytes from hardware random number generator to fill buffer Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.