Struct getrandom::Error

source ·
pub struct Error(_);
Expand description

A small and no_std compatible error type

The Error::raw_os_error() will indicate if the error is from the OS, and if so, which error code the OS gave the application. If such an error is encountered, please consult with your system documentation.

Internally this type is a NonZeroU32, with certain values reserved for certain purposes, see Error::INTERNAL_START and Error::CUSTOM_START.

If this crate’s "std" Cargo feature is enabled, then:

Implementations

This target/platform is not supported by getrandom.

The platform-specific errno returned a non-positive value.

Call to iOS SecRandomCopyBytes failed.

Call to Windows RtlGenRandom failed.

RDRAND instruction failed due to a hardware issue.

RDRAND instruction unsupported on this target.

The environment does not support the Web Crypto API.

Calling Web Crypto API crypto.getRandomValues failed.

On VxWorks, call to randSecure failed (random number generator is not yet initialized).

Node.js does not have the crypto CommonJS module.

Calling Node.js function crypto.randomFillSync failed.

Called from an ES module on Node.js. This is unsupported, see: https://docs.rs/getrandom#nodejs-es-module-support.

Codes below this point represent OS Errors (i.e. positive i32 values). Codes at or above this point, but below Error::CUSTOM_START are reserved for use by the rand and getrandom crates.

Codes at or above this point can be used by users to define their own custom errors.

Extract the raw OS error code (if this error came from the OS)

This method is identical to std::io::Error::raw_os_error(), except that it works in no_std contexts. If this method returns None, the error value can still be formatted via the Display implementation.

Extract the bare error code.

This code can either come from the underlying OS, or be a custom error. Use Error::raw_os_error() to disambiguate.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. 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.