]>
git.proxmox.com Git - rustc.git/blob - vendor/rustix/src/backend/libc/io/errno.rs
1 //! The `rustix` `Errno` type.
3 //! This type holds an OS error code, which conceptually corresponds to an
9 /// The error type for `rustix` APIs.
11 /// This is similar to `std::io::Error`, but only holds an OS error code,
12 /// and no extra error value.
14 #[doc(alias = "errno")]
15 #[derive(Eq, PartialEq, Hash, Copy, Clone)]
16 pub struct Errno(pub(crate) c
::c_int
);
20 #[doc(alias = "ACCES")]
21 pub const ACCESS
: Self = Self(c
::EACCES
);
23 pub const ADDRINUSE
: Self = Self(c
::EADDRINUSE
);
25 pub const ADDRNOTAVAIL
: Self = Self(c
::EADDRNOTAVAIL
);
36 pub const ADV
: Self = Self(c
::EADV
);
38 #[cfg(not(target_os = "l4re"))]
39 pub const AFNOSUPPORT
: Self = Self(c
::EAFNOSUPPORT
);
41 pub const AGAIN
: Self = Self(c
::EAGAIN
);
43 #[cfg(not(target_os = "l4re"))]
44 pub const ALREADY
: Self = Self(c
::EALREADY
);
47 pub const AUTH
: Self = Self(c
::EAUTH
);
58 pub const BADE
: Self = Self(c
::EBADE
);
60 pub const BADF
: Self = Self(c
::EBADF
);
71 pub const BADFD
: Self = Self(c
::EBADFD
);
73 #[cfg(not(any(windows, target_os = "l4re")))]
74 pub const BADMSG
: Self = Self(c
::EBADMSG
);
85 pub const BADR
: Self = Self(c
::EBADR
);
88 pub const BADRPC
: Self = Self(c
::EBADRPC
);
99 pub const BADRQC
: Self = Self(c
::EBADRQC
);
105 target_os
= "espidf",
110 pub const BADSLT
: Self = Self(c
::EBADSLT
);
116 target_os
= "espidf",
121 pub const BFONT
: Self = Self(c
::EBFONT
);
124 pub const BUSY
: Self = Self(c
::EBUSY
);
126 #[cfg(not(target_os = "l4re"))]
127 pub const CANCELED
: Self = Self(c
::ECANCELED
);
129 #[cfg(target_os = "freebsd")]
130 pub const CAPMODE
: Self = Self(c
::ECAPMODE
);
133 pub const CHILD
: Self = Self(c
::ECHILD
);
138 target_os
= "espidf",
143 pub const CHRNG
: Self = Self(c
::ECHRNG
);
149 target_os
= "espidf",
154 pub const COMM
: Self = Self(c
::ECOMM
);
156 pub const CONNABORTED
: Self = Self(c
::ECONNABORTED
);
158 pub const CONNREFUSED
: Self = Self(c
::ECONNREFUSED
);
160 pub const CONNRESET
: Self = Self(c
::ECONNRESET
);
163 pub const DEADLK
: Self = Self(c
::EDEADLK
);
169 target_os
= "android",
170 target_os
= "espidf",
174 pub const DEADLOCK
: Self = Self(c
::EDEADLOCK
);
176 #[cfg(not(target_os = "l4re"))]
177 pub const DESTADDRREQ
: Self = Self(c
::EDESTADDRREQ
);
180 pub const DISCON
: Self = Self(c
::EDISCON
);
183 pub const DOM
: Self = Self(c
::EDOM
);
186 pub const DOOFUS
: Self = Self(c
::EDOOFUS
);
193 target_os
= "espidf",
199 pub const DOTDOT
: Self = Self(c
::EDOTDOT
);
201 pub const DQUOT
: Self = Self(c
::EDQUOT
);
204 pub const EXIST
: Self = Self(c
::EEXIST
);
206 pub const FAULT
: Self = Self(c
::EFAULT
);
209 pub const FBIG
: Self = Self(c
::EFBIG
);
211 #[cfg(any(bsd, target_env = "newlib"))]
212 pub const FTYPE
: Self = Self(c
::EFTYPE
);
214 #[cfg(not(any(target_os = "l4re", target_os = "wasi")))]
215 pub const HOSTDOWN
: Self = Self(c
::EHOSTDOWN
);
217 pub const HOSTUNREACH
: Self = Self(c
::EHOSTUNREACH
);
224 target_os
= "android",
225 target_os
= "espidf",
232 pub const HWPOISON
: Self = Self(c
::EHWPOISON
);
234 #[cfg(not(any(windows, target_os = "l4re")))]
235 pub const IDRM
: Self = Self(c
::EIDRM
);
237 #[cfg(not(any(windows, target_os = "l4re")))]
238 pub const ILSEQ
: Self = Self(c
::EILSEQ
);
240 #[cfg(not(target_os = "l4re"))]
241 pub const INPROGRESS
: Self = Self(c
::EINPROGRESS
);
244 /// For a convenient way to retry system calls that exit with `INTR`, use
245 /// [`retry_on_intr`].
247 /// [`retry_on_intr`]: crate::io::retry_on_intr
248 pub const INTR
: Self = Self(c
::EINTR
);
250 pub const INVAL
: Self = Self(c
::EINVAL
);
251 /// `EINVALIDPROCTABLE`
253 pub const INVALIDPROCTABLE
: Self = Self(c
::EINVALIDPROCTABLE
);
254 /// `EINVALIDPROVIDER`
256 pub const INVALIDPROVIDER
: Self = Self(c
::EINVALIDPROVIDER
);
259 pub const IO
: Self = Self(c
::EIO
);
261 #[cfg(not(target_os = "l4re"))]
262 pub const ISCONN
: Self = Self(c
::EISCONN
);
265 pub const ISDIR
: Self = Self(c
::EISDIR
);
272 target_os
= "espidf",
278 pub const ISNAM
: Self = Self(c
::EISNAM
);
285 target_os
= "espidf",
291 pub const KEYEXPIRED
: Self = Self(c
::EKEYEXPIRED
);
298 target_os
= "espidf",
304 pub const KEYREJECTED
: Self = Self(c
::EKEYREJECTED
);
311 target_os
= "espidf",
317 pub const KEYREVOKED
: Self = Self(c
::EKEYREVOKED
);
322 target_os
= "espidf",
327 pub const L2HLT
: Self = Self(c
::EL2HLT
);
332 target_os
= "espidf",
337 pub const L2NSYNC
: Self = Self(c
::EL2NSYNC
);
342 target_os
= "espidf",
347 pub const L3HLT
: Self = Self(c
::EL3HLT
);
352 target_os
= "espidf",
357 pub const L3RST
: Self = Self(c
::EL3RST
);
363 target_os
= "espidf",
368 pub const LIBACC
: Self = Self(c
::ELIBACC
);
374 target_os
= "espidf",
379 pub const LIBBAD
: Self = Self(c
::ELIBBAD
);
385 target_os
= "espidf",
390 pub const LIBEXEC
: Self = Self(c
::ELIBEXEC
);
396 target_os
= "espidf",
401 pub const LIBMAX
: Self = Self(c
::ELIBMAX
);
407 target_os
= "espidf",
412 pub const LIBSCN
: Self = Self(c
::ELIBSCN
);
417 target_os
= "espidf",
422 pub const LNRNG
: Self = Self(c
::ELNRNG
);
424 pub const LOOP
: Self = Self(c
::ELOOP
);
431 target_os
= "espidf",
437 pub const MEDIUMTYPE
: Self = Self(c
::EMEDIUMTYPE
);
439 pub const MFILE
: Self = Self(c
::EMFILE
);
442 pub const MLINK
: Self = Self(c
::EMLINK
);
444 #[cfg(not(target_os = "l4re"))]
445 pub const MSGSIZE
: Self = Self(c
::EMSGSIZE
);
447 #[cfg(not(any(windows, target_os = "l4re", target_os = "openbsd")))]
448 pub const MULTIHOP
: Self = Self(c
::EMULTIHOP
);
450 pub const NAMETOOLONG
: Self = Self(c
::ENAMETOOLONG
);
457 target_os
= "espidf",
463 pub const NAVAIL
: Self = Self(c
::ENAVAIL
);
466 pub const NEEDAUTH
: Self = Self(c
::ENEEDAUTH
);
468 pub const NETDOWN
: Self = Self(c
::ENETDOWN
);
470 #[cfg(not(target_os = "l4re"))]
471 pub const NETRESET
: Self = Self(c
::ENETRESET
);
473 pub const NETUNREACH
: Self = Self(c
::ENETUNREACH
);
476 pub const NFILE
: Self = Self(c
::ENFILE
);
482 target_os
= "espidf",
487 pub const NOANO
: Self = Self(c
::ENOANO
);
489 #[cfg(any(bsd, target_os = "haiku"))]
490 pub const NOATTR
: Self = Self(c
::ENOATTR
);
492 #[cfg(not(target_os = "l4re"))]
493 pub const NOBUFS
: Self = Self(c
::ENOBUFS
);
498 target_os
= "espidf",
503 pub const NOCSI
: Self = Self(c
::ENOCSI
);
509 target_os
= "openbsd",
512 pub const NODATA
: Self = Self(c
::ENODATA
);
515 pub const NODEV
: Self = Self(c
::ENODEV
);
518 pub const NOENT
: Self = Self(c
::ENOENT
);
521 pub const NOEXEC
: Self = Self(c
::ENOEXEC
);
528 target_os
= "espidf",
534 pub const NOKEY
: Self = Self(c
::ENOKEY
);
536 #[cfg(not(any(windows, target_os = "l4re")))]
537 pub const NOLCK
: Self = Self(c
::ENOLCK
);
539 #[cfg(not(any(windows, target_os = "l4re", target_os = "openbsd")))]
540 pub const NOLINK
: Self = Self(c
::ENOLINK
);
547 target_os
= "espidf",
553 pub const NOMEDIUM
: Self = Self(c
::ENOMEDIUM
);
556 pub const NOMEM
: Self = Self(c
::ENOMEM
);
559 pub const NOMORE
: Self = Self(c
::ENOMORE
);
561 #[cfg(not(any(windows, target_os = "l4re")))]
562 pub const NOMSG
: Self = Self(c
::ENOMSG
);
568 target_os
= "espidf",
573 pub const NONET
: Self = Self(c
::ENONET
);
579 target_os
= "espidf",
584 pub const NOPKG
: Self = Self(c
::ENOPKG
);
586 #[cfg(not(target_os = "l4re"))]
587 pub const NOPROTOOPT
: Self = Self(c
::ENOPROTOOPT
);
590 pub const NOSPC
: Self = Self(c
::ENOSPC
);
597 target_os
= "openbsd",
600 pub const NOSR
: Self = Self(c
::ENOSR
);
607 target_os
= "openbsd",
610 pub const NOSTR
: Self = Self(c
::ENOSTR
);
613 pub const NOSYS
: Self = Self(c
::ENOSYS
);
615 #[cfg(not(any(windows, target_os = "espidf", target_os = "haiku", target_os = "wasi")))]
616 pub const NOTBLK
: Self = Self(c
::ENOTBLK
);
618 #[cfg(any(target_os = "freebsd", target_os = "wasi"))]
619 pub const NOTCAPABLE
: Self = Self(c
::ENOTCAPABLE
);
621 pub const NOTCONN
: Self = Self(c
::ENOTCONN
);
624 pub const NOTDIR
: Self = Self(c
::ENOTDIR
);
626 pub const NOTEMPTY
: Self = Self(c
::ENOTEMPTY
);
633 target_os
= "espidf",
639 pub const NOTNAM
: Self = Self(c
::ENOTNAM
);
640 /// `ENOTRECOVERABLE`
648 pub const NOTRECOVERABLE
: Self = Self(c
::ENOTRECOVERABLE
);
650 #[cfg(not(target_os = "l4re"))]
651 pub const NOTSOCK
: Self = Self(c
::ENOTSOCK
);
653 #[cfg(not(any(windows, target_os = "haiku", target_os = "redox")))]
654 pub const NOTSUP
: Self = Self(c
::ENOTSUP
);
657 pub const NOTTY
: Self = Self(c
::ENOTTY
);
663 target_os
= "espidf",
668 pub const NOTUNIQ
: Self = Self(c
::ENOTUNIQ
);
671 pub const NXIO
: Self = Self(c
::ENXIO
);
673 pub const OPNOTSUPP
: Self = Self(c
::EOPNOTSUPP
);
675 #[cfg(not(any(windows, target_os = "l4re")))]
676 pub const OVERFLOW
: Self = Self(c
::EOVERFLOW
);
685 pub const OWNERDEAD
: Self = Self(c
::EOWNERDEAD
);
688 pub const PERM
: Self = Self(c
::EPERM
);
690 #[cfg(not(any(target_os = "l4re", target_os = "wasi")))]
691 pub const PFNOSUPPORT
: Self = Self(c
::EPFNOSUPPORT
);
694 pub const PIPE
: Self = Self(c
::EPIPE
);
697 pub const PROCLIM
: Self = Self(c
::EPROCLIM
);
700 pub const PROCUNAVAIL
: Self = Self(c
::EPROCUNAVAIL
);
703 pub const PROGMISMATCH
: Self = Self(c
::EPROGMISMATCH
);
706 pub const PROGUNAVAIL
: Self = Self(c
::EPROGUNAVAIL
);
708 #[cfg(not(any(windows, target_os = "l4re")))]
709 pub const PROTO
: Self = Self(c
::EPROTO
);
710 /// `EPROTONOSUPPORT`
711 #[cfg(not(target_os = "l4re"))]
712 pub const PROTONOSUPPORT
: Self = Self(c
::EPROTONOSUPPORT
);
714 #[cfg(not(target_os = "l4re"))]
715 pub const PROTOTYPE
: Self = Self(c
::EPROTOTYPE
);
716 /// `EPROVIDERFAILEDINIT`
718 pub const PROVIDERFAILEDINIT
: Self = Self(c
::EPROVIDERFAILEDINIT
);
721 pub const RANGE
: Self = Self(c
::ERANGE
);
724 pub const REFUSED
: Self = Self(c
::EREFUSED
);
730 target_os
= "espidf",
735 pub const REMCHG
: Self = Self(c
::EREMCHG
);
738 target_os
= "espidf",
743 pub const REMOTE
: Self = Self(c
::EREMOTE
);
750 target_os
= "espidf",
756 pub const REMOTEIO
: Self = Self(c
::EREMOTEIO
);
761 target_os
= "espidf",
766 pub const RESTART
: Self = Self(c
::ERESTART
);
773 target_os
= "android",
774 target_os
= "espidf",
781 pub const RFKILL
: Self = Self(c
::ERFKILL
);
784 pub const ROFS
: Self = Self(c
::EROFS
);
787 pub const RPCMISMATCH
: Self = Self(c
::ERPCMISMATCH
);
789 #[cfg(not(any(target_os = "espidf", target_os = "l4re", target_os = "wasi")))]
790 pub const SHUTDOWN
: Self = Self(c
::ESHUTDOWN
);
791 /// `ESOCKTNOSUPPORT`
793 target_os
= "espidf",
798 pub const SOCKTNOSUPPORT
: Self = Self(c
::ESOCKTNOSUPPORT
);
801 pub const SPIPE
: Self = Self(c
::ESPIPE
);
804 pub const SRCH
: Self = Self(c
::ESRCH
);
810 target_os
= "espidf",
815 pub const SRMNT
: Self = Self(c
::ESRMNT
);
817 pub const STALE
: Self = Self(c
::ESTALE
);
823 target_os
= "espidf",
828 pub const STRPIPE
: Self = Self(c
::ESTRPIPE
);
834 target_os
= "openbsd",
837 pub const TIME
: Self = Self(c
::ETIME
);
839 pub const TIMEDOUT
: Self = Self(c
::ETIMEDOUT
);
842 #[doc(alias = "2BIG")]
843 pub const TOOBIG
: Self = Self(c
::E2BIG
);
845 #[cfg(not(any(target_os = "haiku", target_os = "l4re", target_os = "wasi")))]
846 pub const TOOMANYREFS
: Self = Self(c
::ETOOMANYREFS
);
849 pub const TXTBSY
: Self = Self(c
::ETXTBSY
);
856 target_os
= "espidf",
862 pub const UCLEAN
: Self = Self(c
::EUCLEAN
);
867 target_os
= "espidf",
872 pub const UNATCH
: Self = Self(c
::EUNATCH
);
875 target_os
= "espidf",
880 pub const USERS
: Self = Self(c
::EUSERS
);
882 pub const WOULDBLOCK
: Self = Self(c
::EWOULDBLOCK
);
885 pub const XDEV
: Self = Self(c
::EXDEV
);
891 target_os
= "espidf",
896 pub const XFULL
: Self = Self(c
::EXFULL
);
900 /// Extract an `Errno` value from a `std::io::Error`.
902 /// This isn't a `From` conversion because it's expected to be relatively
904 #[cfg(feature = "std")]
906 pub fn from_io_error(io_err
: &std
::io
::Error
) -> Option
<Self> {
909 .and_then(|raw
| if raw
!= 0 { Some(Self(raw)) }
else { None }
)
912 /// Extract the raw OS error number from this error.
914 pub const fn raw_os_error(self) -> i32 {
918 /// Construct an `Errno` from a raw OS error number.
920 pub const fn from_raw_os_error(raw
: i32) -> Self {
924 pub(crate) fn last_os_error() -> Self {