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