pub struct Error(/* private fields */);
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.
If this crate’s "std"
Cargo feature is enabled, then:
getrandom::Error
implementsstd::error::Error
std::io::Error
implementsFrom<getrandom::Error>
.
Implementations§
Source§impl Error
impl Error
Sourcepub const UNSUPPORTED: Error
pub const UNSUPPORTED: Error
This target/platform is not supported by getrandom
.
Sourcepub const ERRNO_NOT_POSITIVE: Error
pub const ERRNO_NOT_POSITIVE: Error
The platform-specific errno
returned a non-positive value.
Sourcepub const UNEXPECTED: Error
pub const UNEXPECTED: Error
Encountered an unexpected situation which should not happen in practice.
Sourcepub fn raw_os_error(self) -> Option<i32>
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. On most targets this method returns
Option<i32>
, but some platforms (e.g. UEFI) may use a different primitive
type like usize
. Consult with the RawOsError
docs for more information.
If this method returns None
, the error value can still be formatted via
the Display
implementation.
Sourcepub const fn new_custom(n: u16) -> Error
pub const fn new_custom(n: u16) -> Error
Creates a new instance of an Error
from a particular custom error code.
Trait Implementations§
impl Copy for Error
impl Eq for Error
impl StructuralPartialEq for Error
Auto Trait Implementations§
impl Freeze for Error
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 4 bytes