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