Struct rdrand::RdSeed

source ·
pub struct RdSeed(_);
Expand description

A cryptographically secure non-deterministic random bit generator.

This generator produces high-entropy output and is suited to seed other pseudo-random generators.

This instruction currently is only available in Intel Broadwell (and later) and AMD Ryzen processors.

This generator is not intended for general random number generation purposes and should be used to seed other generators implementing rand_core::SeedableRng.

Implementations§

Create a new instance of the random number generator.

This constructor checks whether the CPU the program is running on supports the instruction necessary for this generator to operate. If the instruction is not supported, an error is returned.

Generate a single random u16 value.

The underlying instruction may fail for variety reasons (such as actual hardware failure or exhausted entropy), however the exact reason for the failure is not usually exposed.

This method will retry calling the instruction a few times, however if all the attempts fail, it will return None.

In case None is returned, the caller should assume that an non-recoverable hardware failure has occured and use another random number genrator instead.

Generate a single random u32 value.

The underlying instruction may fail for variety reasons (such as actual hardware failure or exhausted entropy), however the exact reason for the failure is not usually exposed.

This method will retry calling the instruction a few times, however if all the attempts fail, it will return None.

In case None is returned, the caller should assume that an non-recoverable hardware failure has occured and use another random number genrator instead.

Generate a single random u64 value.

The underlying instruction may fail for variety reasons (such as actual hardware failure or exhausted entropy), however the exact reason for the failure is not usually exposed.

This method will retry calling the instruction a few times, however if all the attempts fail, it will return None.

In case None is returned, the caller should assume that an non-recoverable hardware failure has occured and use another random number genrator instead.

Note, that on 32-bit targets, there’s no underlying instruction to generate a 64-bit number, so it is emulated with the 32-bit version of the instruction.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Generate a single random u32 value.

The underlying instruction may fail for variety reasons (such as actual hardware failure or exhausted entropy), however the exact reason for the failure is not usually exposed.

Panic

This method will retry calling the instruction a few times, however if all the attempts fail, it will panic.

In case panic occurs, the caller should assume that an non-recoverable hardware failure has occured and use another random number genrator instead.

Generate a single random u64 value.

The underlying instruction may fail for variety reasons (such as actual hardware failure or exhausted entropy), however the exact reason for the failure is not usually exposed.

Note, that on 32-bit targets, there’s no underlying instruction to generate a 64-bit number, so it is emulated with the 32-bit version of the instruction.

Panic

This method will retry calling the instruction a few times, however if all the attempts fail, it will panic.

In case panic occurs, the caller should assume that an non-recoverable hardware failure has occured and use another random number genrator instead.

Fill a buffer dest with random data.

See try_fill_bytes for a more extensive documentation.

Panic

This method will panic any time try_fill_bytes would return an error.

Fill a buffer dest with random data.

This method will use the most appropriate variant of the instruction available on the machine to achieve the greatest single-core throughput, however it has a slightly higher setup cost than the plain next_u32 or next_u64 methods.

The underlying instruction may fail for variety reasons (such as actual hardware failure or exhausted entropy), however the exact reason for the failure is not usually exposed.

This method will retry calling the instruction a few times, however if all the attempts fail, it will return an error.

If an error is returned, the caller should assume that an non-recoverable hardware failure has occured and use another random number genrator instead.

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 resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.