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§

source§

impl Error

source

pub const UNSUPPORTED: Error = _

This target/platform is not supported by getrandom.

source

pub const ERRNO_NOT_POSITIVE: Error = _

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

source

pub const IOS_SEC_RANDOM: Error = _

Call to iOS SecRandomCopyBytes failed.

source

pub const WINDOWS_RTL_GEN_RANDOM: Error = _

Call to Windows RtlGenRandom failed.

source

pub const FAILED_RDRAND: Error = _

RDRAND instruction failed due to a hardware issue.

source

pub const NO_RDRAND: Error = _

RDRAND instruction unsupported on this target.

source

pub const WEB_CRYPTO: Error = _

The environment does not support the Web Crypto API.

source

pub const WEB_GET_RANDOM_VALUES: Error = _

Calling Web Crypto API crypto.getRandomValues failed.

source

pub const VXWORKS_RAND_SECURE: Error = _

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

source

pub const NODE_CRYPTO: Error = _

Node.js does not have the crypto CommonJS module.

source

pub const NODE_RANDOM_FILL_SYNC: Error = _

Calling Node.js function crypto.randomFillSync failed.

source

pub const NODE_ES_MODULE: Error = _

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

source

pub const INTERNAL_START: u32 = 2_147_483_648u32

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.

source

pub const CUSTOM_START: u32 = 3_221_225_472u32

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

source

pub fn raw_os_error(self) -> Option<i32>

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.

source

pub const fn code(self) -> NonZeroU32

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§

source§

impl Clone for Error

source§

fn clone(&self) -> Error

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Error

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Error

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<NonZeroU32> for Error

source§

fn from(code: NonZeroU32) -> Self

Converts to this type from the input type.
source§

impl PartialEq<Error> for Error

source§

fn eq(&self, other: &Error) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Error

source§

impl Eq for Error

source§

impl StructuralEq for Error

source§

impl StructuralPartialEq for Error

Auto Trait Implementations§

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnwindSafe for Error

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.