]>
git.proxmox.com Git - rustc.git/blob - vendor/wasi-0.9.0+wasi-snapshot-preview1/src/error.rs
3 use core
::num
::NonZeroU16
;
5 /// A raw error returned by wasi APIs, internally containing a 16-bit error
7 #[derive(Copy, Clone, PartialEq, Eq, Ord, PartialOrd)]
13 /// Constructs a new error from a raw error code, returning `None` if the
14 /// error code is zero (which means success).
15 pub fn from_raw_error(error
: Errno
) -> Option
<Error
> {
17 code
: NonZeroU16
::new(error
)?
,
21 /// Returns the raw error code that this error represents.
22 pub fn raw_error(&self) -> u16 {
27 impl fmt
::Display
for Error
{
28 fn fmt(&self, f
: &mut fmt
::Formatter
<'_
>) -> fmt
::Result
{
32 super::strerror(self.code
.get()),
39 impl fmt
::Debug
for Error
{
40 fn fmt(&self, f
: &mut fmt
::Formatter
<'_
>) -> fmt
::Result
{
41 f
.debug_struct("Error")
42 .field("code", &self.code
)
43 .field("message", &super::strerror(self.code
.get()))
48 #[cfg(feature = "std")]
50 #[cfg(feature = "std")]
51 impl std
::error
::Error
for Error {}