Debian Codegraph @

.cargo/vendor/rustix/src/backend/libc/io/errno.rs

raw
1 //! The `rustix` `Errno` type.
2 //!
3 //! This type holds an OS error code, which conceptually corresponds to an
4 //! `errno` value.
5
6 use crate::backend::c;
7 use libc_errno::errno;
8
9 /// `errno`—An error code.
10 ///
11 /// The error type for `rustix` APIs. This is similar to [`std::io::Error`],
12 /// but only holds an OS error code, and no extra error value.
13 ///
14 /// # References
15 /// - [POSIX]
16 /// - [Linux]
17 /// - [Winsock]
18 /// - [FreeBSD]
19 /// - [NetBSD]
20 /// - [OpenBSD]
21 /// - [DragonFly BSD]
22 /// - [illumos]
23 /// - [glibc]
24 ///
25 /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/errno.html
26 /// [Linux]: https://man7.org/linux/man-pages/man3/errno.3.html
27 /// [Winsock]: https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
28 /// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?errno
29 /// [NetBSD]: https://man.netbsd.org/errno.2
30 /// [OpenBSD]: https://man.openbsd.org/errno.2
31 /// [DragonFly BSD]: https://man.dragonflybsd.org/?command=errno&section=2
32 /// [illumos]: https://illumos.org/man/3C/errno
33 /// [glibc]: https://www.gnu.org/software/libc/manual/html_node/Error-Codes.html
34 /// [`std::io::Error`]: Result
35 #[repr(transparent)]
36 #[doc(alias = "errno")]
37 #[derive(Eq, PartialEq, Hash, Copy, Clone)]
38 pub struct Errno(pub(crate) c::c_int);
39
40 impl Errno {
41 /// `EACCES`
42 #[doc(alias = "ACCES")]
43 pub const ACCESS: Self = Self(c::EACCES);
44 /// `EADDRINUSE`
45 pub const ADDRINUSE: Self = Self(c::EADDRINUSE);
46 /// `EADDRNOTAVAIL`
47 pub const ADDRNOTAVAIL: Self = Self(c::EADDRNOTAVAIL);
48 /// `EADV`
49 #[cfg(not(any(
50 bsd,
51 windows,
52 target_os = "aix",
53 target_os = "espidf",
54 target_os = "haiku",
55 target_os = "horizon",
56 target_os = "hurd",
57 target_os = "l4re",
58 target_os = "vita",
59 target_os = "wasi",
60 )))]
61 pub const ADV: Self = Self(c::EADV);
62 /// `EAFNOSUPPORT`
63 #[cfg(not(target_os = "l4re"))]
64 pub const AFNOSUPPORT: Self = Self(c::EAFNOSUPPORT);
65 /// `EAGAIN`
66 pub const AGAIN: Self = Self(c::EAGAIN);
67 /// `EALREADY`
68 #[cfg(not(target_os = "l4re"))]
69 pub const ALREADY: Self = Self(c::EALREADY);
70 /// `EAUTH`
71 #[cfg(bsd)]
72 pub const AUTH: Self = Self(c::EAUTH);
73 /// `EBADE`
74 #[cfg(not(any(
75 bsd,
76 windows,
77 target_os = "aix",
78 target_os = "espidf",
79 target_os = "haiku",
80 target_os = "horizon",
81 target_os = "hurd",
82 target_os = "l4re",
83 target_os = "vita",
84 target_os = "wasi",
85 )))]
86 pub const BADE: Self = Self(c::EBADE);
87 /// `EBADF`
88 pub const BADF: Self = Self(c::EBADF);
89 /// `EBADFD`
90 #[cfg(not(any(
91 bsd,
92 windows,
93 target_os = "aix",
94 target_os = "espidf",
95 target_os = "haiku",
96 target_os = "horizon",
97 target_os = "hurd",
98 target_os = "l4re",
99 target_os = "vita",
100 target_os = "wasi",
101 )))]
102 pub const BADFD: Self = Self(c::EBADFD);
103 /// `EBADMSG`
104 #[cfg(not(any(windows, target_os = "l4re")))]
105 pub const BADMSG: Self = Self(c::EBADMSG);
106 /// `EBADR`
107 #[cfg(not(any(
108 bsd,
109 windows,
110 target_os = "aix",
111 target_os = "espidf",
112 target_os = "haiku",
113 target_os = "horizon",
114 target_os = "hurd",
115 target_os = "l4re",
116 target_os = "vita",
117 target_os = "wasi",
118 )))]
119 pub const BADR: Self = Self(c::EBADR);
120 /// `EBADRPC`
121 #[cfg(bsd)]
122 pub const BADRPC: Self = Self(c::EBADRPC);
123 /// `EBADRQC`
124 #[cfg(not(any(
125 bsd,
126 windows,
127 target_os = "aix",
128 target_os = "espidf",
129 target_os = "haiku",
130 target_os = "horizon",
131 target_os = "hurd",
132 target_os = "l4re",
133 target_os = "vita",
134 target_os = "wasi",
135 )))]
136 pub const BADRQC: Self = Self(c::EBADRQC);
137 /// `EBADSLT`
138 #[cfg(not(any(
139 bsd,
140 windows,
141 target_os = "aix",
142 target_os = "espidf",
143 target_os = "haiku",
144 target_os = "horizon",
145 target_os = "hurd",
146 target_os = "l4re",
147 target_os = "vita",
148 target_os = "wasi",
149 )))]
150 pub const BADSLT: Self = Self(c::EBADSLT);
151 /// `EBFONT`
152 #[cfg(not(any(
153 bsd,
154 windows,
155 target_os = "aix",
156 target_os = "espidf",
157 target_os = "haiku",
158 target_os = "horizon",
159 target_os = "hurd",
160 target_os = "l4re",
161 target_os = "vita",
162 target_os = "wasi",
163 )))]
164 pub const BFONT: Self = Self(c::EBFONT);
165 /// `EBUSY`
166 #[cfg(not(windows))]
167 pub const BUSY: Self = Self(c::EBUSY);
168 /// `ECANCELED`
169 #[cfg(not(target_os = "l4re"))]
170 pub const CANCELED: Self = Self(c::ECANCELED);
171 /// `ECAPMODE`
172 #[cfg(target_os = "freebsd")]
173 pub const CAPMODE: Self = Self(c::ECAPMODE);
174 /// `ECHILD`
175 #[cfg(not(windows))]
176 pub const CHILD: Self = Self(c::ECHILD);
177 /// `ECHRNG`
178 #[cfg(not(any(
179 bsd,
180 windows,
181 target_os = "espidf",
182 target_os = "haiku",
183 target_os = "horizon",
184 target_os = "hurd",
185 target_os = "l4re",
186 target_os = "vita",
187 target_os = "wasi"
188 )))]
189 pub const CHRNG: Self = Self(c::ECHRNG);
190 /// `ECOMM`
191 #[cfg(not(any(
192 bsd,
193 windows,
194 target_os = "aix",
195 target_os = "espidf",
196 target_os = "haiku",
197 target_os = "horizon",
198 target_os = "hurd",
199 target_os = "l4re",
200 target_os = "vita",
201 target_os = "wasi",
202 )))]
203 pub const COMM: Self = Self(c::ECOMM);
204 /// `ECONNABORTED`
205 pub const CONNABORTED: Self = Self(c::ECONNABORTED);
206 /// `ECONNREFUSED`
207 pub const CONNREFUSED: Self = Self(c::ECONNREFUSED);
208 /// `ECONNRESET`
209 pub const CONNRESET: Self = Self(c::ECONNRESET);
210 /// `EDEADLK`
211 #[cfg(not(windows))]
212 pub const DEADLK: Self = Self(c::EDEADLK);
213 /// `EDEADLOCK`
214 #[cfg(not(any(
215 bsd,
216 windows,
217 target_os = "aix",
218 target_os = "android",
219 target_os = "espidf",
220 target_os = "haiku",
221 target_os = "horizon",
222 target_os = "hurd",
223 target_os = "vita",
224 target_os = "wasi",
225 )))]
226 pub const DEADLOCK: Self = Self(c::EDEADLOCK);
227 /// `EDESTADDRREQ`
228 #[cfg(not(target_os = "l4re"))]
229 pub const DESTADDRREQ: Self = Self(c::EDESTADDRREQ);
230 /// `EDISCON`
231 #[cfg(windows)]
232 pub const DISCON: Self = Self(c::EDISCON);
233 /// `EDOM`
234 #[cfg(not(windows))]
235 pub const DOM: Self = Self(c::EDOM);
236 /// `EDOOFUS`
237 #[cfg(freebsdlike)]
238 pub const DOOFUS: Self = Self(c::EDOOFUS);
239 /// `EDOTDOT`
240 #[cfg(not(any(
241 bsd,
242 solarish,
243 windows,
244 target_os = "aix",
245 target_os = "espidf",
246 target_os = "haiku",
247 target_os = "horizon",
248 target_os = "hurd",
249 target_os = "l4re",
250 target_os = "nto",
251 target_os = "vita",
252 target_os = "wasi",
253 )))]
254 pub const DOTDOT: Self = Self(c::EDOTDOT);
255 /// `EDQUOT`
256 pub const DQUOT: Self = Self(c::EDQUOT);
257 /// `EEXIST`
258 #[cfg(not(windows))]
259 pub const EXIST: Self = Self(c::EEXIST);
260 /// `EFAULT`
261 pub const FAULT: Self = Self(c::EFAULT);
262 /// `EFBIG`
263 #[cfg(not(windows))]
264 pub const FBIG: Self = Self(c::EFBIG);
265 /// `EFTYPE`
266 #[cfg(any(bsd, target_env = "newlib"))]
267 pub const FTYPE: Self = Self(c::EFTYPE);
268 /// `EHOSTDOWN`
269 #[cfg(not(any(target_os = "l4re", target_os = "wasi")))]
270 pub const HOSTDOWN: Self = Self(c::EHOSTDOWN);
271 /// `EHOSTUNREACH`
272 pub const HOSTUNREACH: Self = Self(c::EHOSTUNREACH);
273 /// `EHWPOISON`
274 #[cfg(not(any(
275 bsd,
276 solarish,
277 windows,
278 target_os = "aix",
279 target_os = "android",
280 target_os = "espidf",
281 target_os = "haiku",
282 target_os = "horizon",
283 target_os = "hurd",
284 target_os = "l4re",
285 target_os = "nto",
286 target_os = "redox",
287 target_os = "vita",
288 target_os = "wasi",
289 )))]
290 pub const HWPOISON: Self = Self(c::EHWPOISON);
291 /// `EIDRM`
292 #[cfg(not(any(windows, target_os = "l4re")))]
293 pub const IDRM: Self = Self(c::EIDRM);
294 /// `EILSEQ`
295 #[cfg(not(any(windows, target_os = "l4re")))]
296 pub const ILSEQ: Self = Self(c::EILSEQ);
297 /// `EINPROGRESS`
298 #[cfg(not(target_os = "l4re"))]
299 pub const INPROGRESS: Self = Self(c::EINPROGRESS);
300 /// `EINTR`
301 ///
302 /// For a convenient way to retry system calls that exit with `INTR`, use
303 /// [`retry_on_intr`].
304 ///
305 /// [`retry_on_intr`]: crate::io::retry_on_intr
306 pub const INTR: Self = Self(c::EINTR);
307 /// `EINVAL`
308 pub const INVAL: Self = Self(c::EINVAL);
309 /// `EINVALIDPROCTABLE`
310 #[cfg(windows)]
311 pub const INVALIDPROCTABLE: Self = Self(c::EINVALIDPROCTABLE);
312 /// `EINVALIDPROVIDER`
313 #[cfg(windows)]
314 pub const INVALIDPROVIDER: Self = Self(c::EINVALIDPROVIDER);
315 /// `EIO`
316 #[cfg(not(windows))]
317 pub const IO: Self = Self(c::EIO);
318 /// `EISCONN`
319 #[cfg(not(target_os = "l4re"))]
320 pub const ISCONN: Self = Self(c::EISCONN);
321 /// `EISDIR`
322 #[cfg(not(windows))]
323 pub const ISDIR: Self = Self(c::EISDIR);
324 /// `EISNAM`
325 #[cfg(not(any(
326 bsd,
327 solarish,
328 windows,
329 target_os = "aix",
330 target_os = "espidf",
331 target_os = "haiku",
332 target_os = "horizon",
333 target_os = "hurd",
334 target_os = "l4re",
335 target_os = "nto",
336 target_os = "vita",
337 target_os = "wasi",
338 )))]
339 pub const ISNAM: Self = Self(c::EISNAM);
340 /// `EKEYEXPIRED`
341 #[cfg(not(any(
342 bsd,
343 solarish,
344 windows,
345 target_os = "aix",
346 target_os = "espidf",
347 target_os = "haiku",
348 target_os = "horizon",
349 target_os = "hurd",
350 target_os = "l4re",
351 target_os = "nto",
352 target_os = "vita",
353 target_os = "wasi",
354 )))]
355 pub const KEYEXPIRED: Self = Self(c::EKEYEXPIRED);
356 /// `EKEYREJECTED`
357 #[cfg(not(any(
358 bsd,
359 solarish,
360 windows,
361 target_os = "aix",
362 target_os = "espidf",
363 target_os = "haiku",
364 target_os = "horizon",
365 target_os = "hurd",
366 target_os = "l4re",
367 target_os = "nto",
368 target_os = "vita",
369 target_os = "wasi",
370 )))]
371 pub const KEYREJECTED: Self = Self(c::EKEYREJECTED);
372 /// `EKEYREVOKED`
373 #[cfg(not(any(
374 bsd,
375 solarish,
376 windows,
377 target_os = "aix",
378 target_os = "espidf",
379 target_os = "haiku",
380 target_os = "horizon",
381 target_os = "hurd",
382 target_os = "l4re",
383 target_os = "nto",
384 target_os = "vita",
385 target_os = "wasi",
386 )))]
387 pub const KEYREVOKED: Self = Self(c::EKEYREVOKED);
388 /// `EL2HLT`
389 #[cfg(not(any(
390 bsd,
391 windows,
392 target_os = "espidf",
393 target_os = "haiku",
394 target_os = "horizon",
395 target_os = "hurd",
396 target_os = "l4re",
397 target_os = "vita",
398 target_os = "wasi"
399 )))]
400 pub const L2HLT: Self = Self(c::EL2HLT);
401 /// `EL2NSYNC`
402 #[cfg(not(any(
403 bsd,
404 windows,
405 target_os = "espidf",
406 target_os = "haiku",
407 target_os = "horizon",
408 target_os = "hurd",
409 target_os = "l4re",
410 target_os = "vita",
411 target_os = "wasi"
412 )))]
413 pub const L2NSYNC: Self = Self(c::EL2NSYNC);
414 /// `EL3HLT`
415 #[cfg(not(any(
416 bsd,
417 windows,
418 target_os = "espidf",
419 target_os = "haiku",
420 target_os = "horizon",
421 target_os = "hurd",
422 target_os = "l4re",
423 target_os = "vita",
424 target_os = "wasi"
425 )))]
426 pub const L3HLT: Self = Self(c::EL3HLT);
427 /// `EL3RST`
428 #[cfg(not(any(
429 bsd,
430 windows,
431 target_os = "espidf",
432 target_os = "haiku",
433 target_os = "horizon",
434 target_os = "hurd",
435 target_os = "l4re",
436 target_os = "vita",
437 target_os = "wasi"
438 )))]
439 pub const L3RST: Self = Self(c::EL3RST);
440 /// `ELIBACC`
441 #[cfg(not(any(
442 bsd,
443 windows,
444 target_os = "aix",
445 target_os = "espidf",
446 target_os = "haiku",
447 target_os = "horizon",
448 target_os = "hurd",
449 target_os = "l4re",
450 target_os = "vita",
451 target_os = "wasi",
452 )))]
453 pub const LIBACC: Self = Self(c::ELIBACC);
454 /// `ELIBBAD`
455 #[cfg(not(any(
456 bsd,
457 windows,
458 target_os = "aix",
459 target_os = "espidf",
460 target_os = "haiku",
461 target_os = "horizon",
462 target_os = "hurd",
463 target_os = "l4re",
464 target_os = "vita",
465 target_os = "wasi",
466 )))]
467 pub const LIBBAD: Self = Self(c::ELIBBAD);
468 /// `ELIBEXEC`
469 #[cfg(not(any(
470 bsd,
471 windows,
472 target_os = "aix",
473 target_os = "espidf",
474 target_os = "haiku",
475 target_os = "horizon",
476 target_os = "l4re",
477 target_os = "vita",
478 target_os = "wasi",
479 )))]
480 pub const LIBEXEC: Self = Self(c::ELIBEXEC);
481 /// `ELIBMAX`
482 #[cfg(not(any(
483 bsd,
484 windows,
485 target_os = "aix",
486 target_os = "espidf",
487 target_os = "haiku",
488 target_os = "horizon",
489 target_os = "hurd",
490 target_os = "l4re",
491 target_os = "vita",
492 target_os = "wasi",
493 )))]
494 pub const LIBMAX: Self = Self(c::ELIBMAX);
495 /// `ELIBSCN`
496 #[cfg(not(any(
497 bsd,
498 windows,
499 target_os = "aix",
500 target_os = "espidf",
501 target_os = "haiku",
502 target_os = "horizon",
503 target_os = "hurd",
504 target_os = "l4re",
505 target_os = "vita",
506 target_os = "wasi",
507 )))]
508 pub const LIBSCN: Self = Self(c::ELIBSCN);
509 /// `ELNRNG`
510 #[cfg(not(any(
511 bsd,
512 windows,
513 target_os = "espidf",
514 target_os = "haiku",
515 target_os = "horizon",
516 target_os = "hurd",
517 target_os = "l4re",
518 target_os = "vita",
519 target_os = "wasi"
520 )))]
521 pub const LNRNG: Self = Self(c::ELNRNG);
522 /// `ELOOP`
523 pub const LOOP: Self = Self(c::ELOOP);
524 /// `EMEDIUMTYPE`
525 #[cfg(not(any(
526 bsd,
527 solarish,
528 windows,
529 target_os = "aix",
530 target_os = "espidf",
531 target_os = "haiku",
532 target_os = "horizon",
533 target_os = "hurd",
534 target_os = "l4re",
535 target_os = "nto",
536 target_os = "vita",
537 target_os = "wasi",
538 )))]
539 pub const MEDIUMTYPE: Self = Self(c::EMEDIUMTYPE);
540 /// `EMFILE`
541 pub const MFILE: Self = Self(c::EMFILE);
542 /// `EMLINK`
543 #[cfg(not(windows))]
544 pub const MLINK: Self = Self(c::EMLINK);
545 /// `EMSGSIZE`
546 #[cfg(not(target_os = "l4re"))]
547 pub const MSGSIZE: Self = Self(c::EMSGSIZE);
548 /// `EMULTIHOP`
549 #[cfg(not(any(windows, target_os = "l4re", target_os = "openbsd")))]
550 pub const MULTIHOP: Self = Self(c::EMULTIHOP);
551 /// `ENAMETOOLONG`
552 pub const NAMETOOLONG: Self = Self(c::ENAMETOOLONG);
553 /// `ENAVAIL`
554 #[cfg(not(any(
555 bsd,
556 solarish,
557 windows,
558 target_os = "aix",
559 target_os = "espidf",
560 target_os = "haiku",
561 target_os = "horizon",
562 target_os = "hurd",
563 target_os = "l4re",
564 target_os = "nto",
565 target_os = "vita",
566 target_os = "wasi",
567 )))]
568 pub const NAVAIL: Self = Self(c::ENAVAIL);
569 /// `ENEEDAUTH`
570 #[cfg(bsd)]
571 pub const NEEDAUTH: Self = Self(c::ENEEDAUTH);
572 /// `ENETDOWN`
573 pub const NETDOWN: Self = Self(c::ENETDOWN);
574 /// `ENETRESET`
575 #[cfg(not(target_os = "l4re"))]
576 pub const NETRESET: Self = Self(c::ENETRESET);
577 /// `ENETUNREACH`
578 pub const NETUNREACH: Self = Self(c::ENETUNREACH);
579 /// `ENFILE`
580 #[cfg(not(windows))]
581 pub const NFILE: Self = Self(c::ENFILE);
582 /// `ENOANO`
583 #[cfg(not(any(
584 bsd,
585 windows,
586 target_os = "aix",
587 target_os = "espidf",
588 target_os = "haiku",
589 target_os = "horizon",
590 target_os = "hurd",
591 target_os = "l4re",
592 target_os = "vita",
593 target_os = "wasi",
594 )))]
595 pub const NOANO: Self = Self(c::ENOANO);
596 /// `ENOATTR`
597 #[cfg(any(bsd, target_os = "haiku"))]
598 pub const NOATTR: Self = Self(c::ENOATTR);
599 /// `ENOBUFS`
600 #[cfg(not(target_os = "l4re"))]
601 pub const NOBUFS: Self = Self(c::ENOBUFS);
602 /// `ENOCSI`
603 #[cfg(not(any(
604 bsd,
605 windows,
606 target_os = "espidf",
607 target_os = "haiku",
608 target_os = "horizon",
609 target_os = "hurd",
610 target_os = "l4re",
611 target_os = "vita",
612 target_os = "wasi"
613 )))]
614 pub const NOCSI: Self = Self(c::ENOCSI);
615 /// `ENODATA`
616 #[cfg(not(any(
617 freebsdlike,
618 windows,
619 target_os = "haiku",
620 target_os = "openbsd",
621 target_os = "wasi",
622 )))]
623 pub const NODATA: Self = Self(c::ENODATA);
624 /// `ENODEV`
625 #[cfg(not(windows))]
626 pub const NODEV: Self = Self(c::ENODEV);
627 /// `ENOENT`
628 #[cfg(not(windows))]
629 pub const NOENT: Self = Self(c::ENOENT);
630 /// `ENOEXEC`
631 #[cfg(not(windows))]
632 pub const NOEXEC: Self = Self(c::ENOEXEC);
633 /// `ENOKEY`
634 #[cfg(not(any(
635 solarish,
636 bsd,
637 windows,
638 target_os = "aix",
639 target_os = "espidf",
640 target_os = "haiku",
641 target_os = "horizon",
642 target_os = "hurd",
643 target_os = "l4re",
644 target_os = "nto",
645 target_os = "vita",
646 target_os = "wasi",
647 )))]
648 pub const NOKEY: Self = Self(c::ENOKEY);
649 /// `ENOLCK`
650 #[cfg(not(any(windows, target_os = "l4re")))]
651 pub const NOLCK: Self = Self(c::ENOLCK);
652 /// `ENOLINK`
653 #[cfg(not(any(windows, target_os = "l4re", target_os = "openbsd")))]
654 pub const NOLINK: Self = Self(c::ENOLINK);
655 /// `ENOMEDIUM`
656 #[cfg(not(any(
657 bsd,
658 solarish,
659 windows,
660 target_os = "aix",
661 target_os = "espidf",
662 target_os = "haiku",
663 target_os = "horizon",
664 target_os = "hurd",
665 target_os = "l4re",
666 target_os = "nto",
667 target_os = "vita",
668 target_os = "wasi",
669 )))]
670 pub const NOMEDIUM: Self = Self(c::ENOMEDIUM);
671 /// `ENOMEM`
672 #[cfg(not(windows))]
673 pub const NOMEM: Self = Self(c::ENOMEM);
674 /// `ENOMORE`
675 #[cfg(windows)]
676 pub const NOMORE: Self = Self(c::ENOMORE);
677 /// `ENOMSG`
678 #[cfg(not(any(windows, target_os = "l4re")))]
679 pub const NOMSG: Self = Self(c::ENOMSG);
680 /// `ENONET`
681 #[cfg(not(any(
682 bsd,
683 windows,
684 target_os = "aix",
685 target_os = "espidf",
686 target_os = "haiku",
687 target_os = "horizon",
688 target_os = "hurd",
689 target_os = "l4re",
690 target_os = "vita",
691 target_os = "wasi",
692 )))]
693 pub const NONET: Self = Self(c::ENONET);
694 /// `ENOPKG`
695 #[cfg(not(any(
696 bsd,
697 windows,
698 target_os = "aix",
699 target_os = "espidf",
700 target_os = "haiku",
701 target_os = "horizon",
702 target_os = "hurd",
703 target_os = "l4re",
704 target_os = "vita",
705 target_os = "wasi",
706 )))]
707 pub const NOPKG: Self = Self(c::ENOPKG);
708 /// `ENOPROTOOPT`
709 #[cfg(not(target_os = "l4re"))]
710 pub const NOPROTOOPT: Self = Self(c::ENOPROTOOPT);
711 /// `ENOSPC`
712 #[cfg(not(windows))]
713 pub const NOSPC: Self = Self(c::ENOSPC);
714 /// `ENOSR`
715 #[cfg(not(any(
716 freebsdlike,
717 windows,
718 target_os = "haiku",
719 target_os = "l4re",
720 target_os = "openbsd",
721 target_os = "wasi",
722 )))]
723 pub const NOSR: Self = Self(c::ENOSR);
724 /// `ENOSTR`
725 #[cfg(not(any(
726 freebsdlike,
727 windows,
728 target_os = "haiku",
729 target_os = "l4re",
730 target_os = "openbsd",
731 target_os = "wasi",
732 )))]
733 pub const NOSTR: Self = Self(c::ENOSTR);
734 /// `ENOSYS`
735 #[cfg(not(windows))]
736 pub const NOSYS: Self = Self(c::ENOSYS);
737 /// `ENOTBLK`
738 #[cfg(not(any(
739 windows,
740 target_os = "espidf",
741 target_os = "haiku",
742 target_os = "horizon",
743 target_os = "vita",
744 target_os = "wasi"
745 )))]
746 pub const NOTBLK: Self = Self(c::ENOTBLK);
747 /// `ENOTCAPABLE`
748 #[cfg(any(target_os = "freebsd", target_os = "wasi"))]
749 pub const NOTCAPABLE: Self = Self(c::ENOTCAPABLE);
750 /// `ENOTCONN`
751 pub const NOTCONN: Self = Self(c::ENOTCONN);
752 /// `ENOTDIR`
753 #[cfg(not(windows))]
754 pub const NOTDIR: Self = Self(c::ENOTDIR);
755 /// `ENOTEMPTY`
756 pub const NOTEMPTY: Self = Self(c::ENOTEMPTY);
757 /// `ENOTNAM`
758 #[cfg(not(any(
759 bsd,
760 solarish,
761 windows,
762 target_os = "aix",
763 target_os = "espidf",
764 target_os = "haiku",
765 target_os = "horizon",
766 target_os = "hurd",
767 target_os = "l4re",
768 target_os = "nto",
769 target_os = "vita",
770 target_os = "wasi",
771 )))]
772 pub const NOTNAM: Self = Self(c::ENOTNAM);
773 /// `ENOTRECOVERABLE`
774 #[cfg(not(any(
775 freebsdlike,
776 netbsdlike,
777 windows,
778 target_os = "haiku",
779 target_os = "l4re"
780 )))]
781 pub const NOTRECOVERABLE: Self = Self(c::ENOTRECOVERABLE);
782 /// `ENOTSOCK`
783 #[cfg(not(target_os = "l4re"))]
784 pub const NOTSOCK: Self = Self(c::ENOTSOCK);
785 /// `ENOTSUP`
786 #[cfg(not(any(windows, target_os = "haiku", target_os = "redox")))]
787 pub const NOTSUP: Self = Self(c::ENOTSUP);
788 /// `ENOTTY`
789 #[cfg(not(windows))]
790 pub const NOTTY: Self = Self(c::ENOTTY);
791 /// `ENOTUNIQ`
792 #[cfg(not(any(
793 bsd,
794 windows,
795 target_os = "aix",
796 target_os = "espidf",
797 target_os = "haiku",
798 target_os = "horizon",
799 target_os = "hurd",
800 target_os = "l4re",
801 target_os = "vita",
802 target_os = "wasi",
803 )))]
804 pub const NOTUNIQ: Self = Self(c::ENOTUNIQ);
805 /// `ENXIO`
806 #[cfg(not(windows))]
807 pub const NXIO: Self = Self(c::ENXIO);
808 /// `EOPNOTSUPP`
809 pub const OPNOTSUPP: Self = Self(c::EOPNOTSUPP);
810 /// `EOVERFLOW`
811 #[cfg(not(any(windows, target_os = "l4re")))]
812 pub const OVERFLOW: Self = Self(c::EOVERFLOW);
813 /// `EOWNERDEAD`
814 #[cfg(not(any(
815 freebsdlike,
816 netbsdlike,
817 windows,
818 target_os = "haiku",
819 target_os = "l4re"
820 )))]
821 pub const OWNERDEAD: Self = Self(c::EOWNERDEAD);
822 /// `EPERM`
823 #[cfg(not(windows))]
824 pub const PERM: Self = Self(c::EPERM);
825 /// `EPFNOSUPPORT`
826 #[cfg(not(any(target_os = "l4re", target_os = "wasi")))]
827 pub const PFNOSUPPORT: Self = Self(c::EPFNOSUPPORT);
828 /// `EPIPE`
829 #[cfg(not(windows))]
830 pub const PIPE: Self = Self(c::EPIPE);
831 /// `EPROCLIM`
832 #[cfg(bsd)]
833 pub const PROCLIM: Self = Self(c::EPROCLIM);
834 /// `EPROCUNAVAIL`
835 #[cfg(bsd)]
836 pub const PROCUNAVAIL: Self = Self(c::EPROCUNAVAIL);
837 /// `EPROGMISMATCH`
838 #[cfg(bsd)]
839 pub const PROGMISMATCH: Self = Self(c::EPROGMISMATCH);
840 /// `EPROGUNAVAIL`
841 #[cfg(bsd)]
842 pub const PROGUNAVAIL: Self = Self(c::EPROGUNAVAIL);
843 /// `EPROTO`
844 #[cfg(not(any(windows, target_os = "l4re")))]
845 pub const PROTO: Self = Self(c::EPROTO);
846 /// `EPROTONOSUPPORT`
847 #[cfg(not(target_os = "l4re"))]
848 pub const PROTONOSUPPORT: Self = Self(c::EPROTONOSUPPORT);
849 /// `EPROTOTYPE`
850 #[cfg(not(target_os = "l4re"))]
851 pub const PROTOTYPE: Self = Self(c::EPROTOTYPE);
852 /// `EPROVIDERFAILEDINIT`
853 #[cfg(windows)]
854 pub const PROVIDERFAILEDINIT: Self = Self(c::EPROVIDERFAILEDINIT);
855 /// `ERANGE`
856 #[cfg(not(windows))]
857 pub const RANGE: Self = Self(c::ERANGE);
858 /// `EREFUSED`
859 #[cfg(windows)]
860 pub const REFUSED: Self = Self(c::EREFUSED);
861 /// `EREMCHG`
862 #[cfg(not(any(
863 bsd,
864 windows,
865 target_os = "aix",
866 target_os = "espidf",
867 target_os = "haiku",
868 target_os = "horizon",
869 target_os = "hurd",
870 target_os = "l4re",
871 target_os = "vita",
872 target_os = "wasi",
873 )))]
874 pub const REMCHG: Self = Self(c::EREMCHG);
875 /// `EREMOTE`
876 #[cfg(not(any(
877 target_os = "espidf",
878 target_os = "haiku",
879 target_os = "horizon",
880 target_os = "l4re",
881 target_os = "vita",
882 target_os = "wasi"
883 )))]
884 pub const REMOTE: Self = Self(c::EREMOTE);
885 /// `EREMOTEIO`
886 #[cfg(not(any(
887 bsd,
888 solarish,
889 windows,
890 target_os = "aix",
891 target_os = "espidf",
892 target_os = "haiku",
893 target_os = "horizon",
894 target_os = "hurd",
895 target_os = "l4re",
896 target_os = "nto",
897 target_os = "vita",
898 target_os = "wasi",
899 )))]
900 pub const REMOTEIO: Self = Self(c::EREMOTEIO);
901 /// `ERESTART`
902 #[cfg(not(any(
903 bsd,
904 windows,
905 target_os = "espidf",
906 target_os = "haiku",
907 target_os = "horizon",
908 target_os = "hurd",
909 target_os = "l4re",
910 target_os = "vita",
911 target_os = "wasi"
912 )))]
913 pub const RESTART: Self = Self(c::ERESTART);
914 /// `ERFKILL`
915 #[cfg(not(any(
916 bsd,
917 solarish,
918 windows,
919 target_os = "aix",
920 target_os = "android",
921 target_os = "espidf",
922 target_os = "haiku",
923 target_os = "horizon",
924 target_os = "hurd",
925 target_os = "l4re",
926 target_os = "nto",
927 target_os = "redox",
928 target_os = "vita",
929 target_os = "wasi",
930 )))]
931 pub const RFKILL: Self = Self(c::ERFKILL);
932 /// `EROFS`
933 #[cfg(not(windows))]
934 pub const ROFS: Self = Self(c::EROFS);
935 /// `ERPCMISMATCH`
936 #[cfg(bsd)]
937 pub const RPCMISMATCH: Self = Self(c::ERPCMISMATCH);
938 /// `ESHUTDOWN`
939 #[cfg(not(any(
940 target_os = "espidf",
941 target_os = "horizon",
942 target_os = "l4re",
943 target_os = "vita",
944 target_os = "wasi"
945 )))]
946 pub const SHUTDOWN: Self = Self(c::ESHUTDOWN);
947 /// `ESOCKTNOSUPPORT`
948 #[cfg(not(any(
949 target_os = "espidf",
950 target_os = "haiku",
951 target_os = "horizon",
952 target_os = "l4re",
953 target_os = "vita",
954 target_os = "wasi"
955 )))]
956 pub const SOCKTNOSUPPORT: Self = Self(c::ESOCKTNOSUPPORT);
957 /// `ESPIPE`
958 #[cfg(not(windows))]
959 pub const SPIPE: Self = Self(c::ESPIPE);
960 /// `ESRCH`
961 #[cfg(not(windows))]
962 pub const SRCH: Self = Self(c::ESRCH);
963 /// `ESRMNT`
964 #[cfg(not(any(
965 bsd,
966 windows,
967 target_os = "aix",
968 target_os = "espidf",
969 target_os = "haiku",
970 target_os = "horizon",
971 target_os = "hurd",
972 target_os = "l4re",
973 target_os = "vita",
974 target_os = "wasi",
975 )))]
976 pub const SRMNT: Self = Self(c::ESRMNT);
977 /// `ESTALE`
978 pub const STALE: Self = Self(c::ESTALE);
979 /// `ESTRPIPE`
980 #[cfg(not(any(
981 bsd,
982 windows,
983 target_os = "aix",
984 target_os = "espidf",
985 target_os = "haiku",
986 target_os = "horizon",
987 target_os = "hurd",
988 target_os = "l4re",
989 target_os = "vita",
990 target_os = "wasi",
991 )))]
992 pub const STRPIPE: Self = Self(c::ESTRPIPE);
993 /// `ETIME`
994 #[cfg(not(any(
995 freebsdlike,
996 windows,
997 target_os = "l4re",
998 target_os = "openbsd",
999 target_os = "wasi"
1000 )))]
1001 pub const TIME: Self = Self(c::ETIME);
1002 /// `ETIMEDOUT`
1003 pub const TIMEDOUT: Self = Self(c::ETIMEDOUT);
1004 /// `E2BIG`
1005 #[cfg(not(windows))]
1006 #[doc(alias = "2BIG")]
1007 pub const TOOBIG: Self = Self(c::E2BIG);
1008 /// `ETOOMANYREFS`
1009 #[cfg(not(any(target_os = "haiku", target_os = "l4re", target_os = "wasi")))]
1010 pub const TOOMANYREFS: Self = Self(c::ETOOMANYREFS);
1011 /// `ETXTBSY`
1012 #[cfg(not(windows))]
1013 pub const TXTBSY: Self = Self(c::ETXTBSY);
1014 /// `EUCLEAN`
1015 #[cfg(not(any(
1016 bsd,
1017 solarish,
1018 windows,
1019 target_os = "aix",
1020 target_os = "espidf",
1021 target_os = "haiku",
1022 target_os = "horizon",
1023 target_os = "hurd",
1024 target_os = "l4re",
1025 target_os = "nto",
1026 target_os = "vita",
1027 target_os = "wasi",
1028 )))]
1029 pub const UCLEAN: Self = Self(c::EUCLEAN);
1030 /// `EUNATCH`
1031 #[cfg(not(any(
1032 bsd,
1033 windows,
1034 target_os = "espidf",
1035 target_os = "haiku",
1036 target_os = "horizon",
1037 target_os = "hurd",
1038 target_os = "l4re",
1039 target_os = "vita",
1040 target_os = "wasi"
1041 )))]
1042 pub const UNATCH: Self = Self(c::EUNATCH);
1043 /// `EUSERS`
1044 #[cfg(not(any(
1045 target_os = "espidf",
1046 target_os = "haiku",
1047 target_os = "horizon",
1048 target_os = "l4re",
1049 target_os = "vita",
1050 target_os = "wasi"
1051 )))]
1052 pub const USERS: Self = Self(c::EUSERS);
1053 /// `EWOULDBLOCK`
1054 pub const WOULDBLOCK: Self = Self(c::EWOULDBLOCK);
1055 /// `EXDEV`
1056 #[cfg(not(windows))]
1057 pub const XDEV: Self = Self(c::EXDEV);
1058 /// `EXFULL`
1059 #[cfg(not(any(
1060 bsd,
1061 windows,
1062 target_os = "aix",
1063 target_os = "espidf",
1064 target_os = "haiku",
1065 target_os = "horizon",
1066 target_os = "hurd",
1067 target_os = "l4re",
1068 target_os = "vita",
1069 target_os = "wasi",
1070 )))]
1071 pub const XFULL: Self = Self(c::EXFULL);
1072 }
1073
1074 impl Errno {
1075 /// Extract an `Errno` value from a `std::io::Error`.
1076 ///
1077 /// This isn't a `From` conversion because it's expected to be relatively
1078 /// uncommon.
1079 #[cfg(feature = "std")]
1080 #[inline]
1081 pub fn from_io_error(io_err: &std::io::Error) -> Option<Self> {
1082 io_err
1083 .raw_os_error()
1084 .and_then(|raw| if raw != 0 { Some(Self(raw)) } else { None })
1085 }
1086
1087 /// Extract the raw OS error number from this error.
1088 #[inline]
1089 pub const fn raw_os_error(self) -> i32 {
1090 self.0
1091 }
1092
1093 /// Construct an `Errno` from a raw OS error number.
1094 #[inline]
1095 pub const fn from_raw_os_error(raw: i32) -> Self {
1096 Self(raw)
1097 }
1098
1099 pub(crate) fn last_os_error() -> Self {
1100 Self(errno().0)
1101 }
1102 }