pub type RawErrno = i32;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[repr(transparent)]
pub struct Errno(pub RawErrno);
impl Errno {
pub const NO_ERROR: Self = Self(0);
}
#[doc = include_str!("errno.md")]
#[cfg(unix)]
impl Errno {
pub const E2BIG: Self = Self(libc::E2BIG as _);
pub const EACCES: Self = Self(libc::EACCES as _);
pub const EADDRINUSE: Self = Self(libc::EADDRINUSE as _);
pub const EADDRNOTAVAIL: Self = Self(libc::EADDRNOTAVAIL as _);
pub const EAFNOSUPPORT: Self = Self(libc::EAFNOSUPPORT as _);
pub const EAGAIN: Self = Self(libc::EAGAIN as _);
pub const EALREADY: Self = Self(libc::EALREADY as _);
pub const EBADF: Self = Self(libc::EBADF as _);
pub const EBADMSG: Self = Self(libc::EBADMSG as _);
pub const EBUSY: Self = Self(libc::EBUSY as _);
pub const ECANCELED: Self = Self(libc::ECANCELED as _);
pub const ECHILD: Self = Self(libc::ECHILD as _);
pub const ECONNABORTED: Self = Self(libc::ECONNABORTED as _);
pub const ECONNREFUSED: Self = Self(libc::ECONNREFUSED as _);
pub const ECONNRESET: Self = Self(libc::ECONNRESET as _);
pub const EDEADLK: Self = Self(libc::EDEADLK as _);
pub const EDESTADDRREQ: Self = Self(libc::EDESTADDRREQ as _);
pub const EDOM: Self = Self(libc::EDOM as _);
pub const EDQUOT: Self = Self(libc::EDQUOT as _);
pub const EEXIST: Self = Self(libc::EEXIST as _);
pub const EFAULT: Self = Self(libc::EFAULT as _);
pub const EFBIG: Self = Self(libc::EFBIG as _);
pub const EHOSTUNREACH: Self = Self(libc::EHOSTUNREACH as _);
pub const EIDRM: Self = Self(libc::EIDRM as _);
pub const EILSEQ: Self = Self(libc::EILSEQ as _);
pub const EINPROGRESS: Self = Self(libc::EINPROGRESS as _);
pub const EINTR: Self = Self(libc::EINTR as _);
pub const EINVAL: Self = Self(libc::EINVAL as _);
pub const EIO: Self = Self(libc::EIO as _);
pub const EISCONN: Self = Self(libc::EISCONN as _);
pub const EISDIR: Self = Self(libc::EISDIR as _);
pub const ELOOP: Self = Self(libc::ELOOP as _);
pub const EMFILE: Self = Self(libc::EMFILE as _);
pub const EMLINK: Self = Self(libc::EMLINK as _);
pub const EMSGSIZE: Self = Self(libc::EMSGSIZE as _);
pub const ENAMETOOLONG: Self = Self(libc::ENAMETOOLONG as _);
pub const ENETDOWN: Self = Self(libc::ENETDOWN as _);
pub const ENETRESET: Self = Self(libc::ENETRESET as _);
pub const ENETUNREACH: Self = Self(libc::ENETUNREACH as _);
pub const ENFILE: Self = Self(libc::ENFILE as _);
pub const ENOBUFS: Self = Self(libc::ENOBUFS as _);
pub const ENODEV: Self = Self(libc::ENODEV as _);
pub const ENOENT: Self = Self(libc::ENOENT as _);
pub const ENOEXEC: Self = Self(libc::ENOEXEC as _);
pub const ENOLCK: Self = Self(libc::ENOLCK as _);
pub const ENOMEM: Self = Self(libc::ENOMEM as _);
pub const ENOMSG: Self = Self(libc::ENOMSG as _);
pub const ENOPROTOOPT: Self = Self(libc::ENOPROTOOPT as _);
pub const ENOSPC: Self = Self(libc::ENOSPC as _);
pub const ENOSYS: Self = Self(libc::ENOSYS as _);
pub const ENOTCONN: Self = Self(libc::ENOTCONN as _);
pub const ENOTDIR: Self = Self(libc::ENOTDIR as _);
pub const ENOTEMPTY: Self = Self(libc::ENOTEMPTY as _);
pub const ENOTSOCK: Self = Self(libc::ENOTSOCK as _);
pub const ENOTSUP: Self = Self(libc::ENOTSUP as _);
pub const ENOTTY: Self = Self(libc::ENOTTY as _);
pub const ENXIO: Self = Self(libc::ENXIO as _);
pub const EOPNOTSUPP: Self = Self(libc::EOPNOTSUPP as _);
pub const EOVERFLOW: Self = Self(libc::EOVERFLOW as _);
pub const EPERM: Self = Self(libc::EPERM as _);
pub const EPIPE: Self = Self(libc::EPIPE as _);
pub const EPROTO: Self = Self(libc::EPROTO as _);
pub const EPROTONOSUPPORT: Self = Self(libc::EPROTONOSUPPORT as _);
pub const EPROTOTYPE: Self = Self(libc::EPROTOTYPE as _);
pub const ERANGE: Self = Self(libc::ERANGE as _);
pub const EROFS: Self = Self(libc::EROFS as _);
pub const ESPIPE: Self = Self(libc::ESPIPE as _);
pub const ESRCH: Self = Self(libc::ESRCH as _);
pub const ESTALE: Self = Self(libc::ESTALE as _);
pub const ETIMEDOUT: Self = Self(libc::ETIMEDOUT as _);
pub const ETXTBSY: Self = Self(libc::ETXTBSY as _);
pub const EWOULDBLOCK: Self = Self(libc::EWOULDBLOCK as _);
pub const EXDEV: Self = Self(libc::EXDEV as _);
}
#[doc = include_str!("errno.md")]
#[cfg(not(unix))]
impl Errno {
pub const E2BIG: Self = Self(1);
pub const EACCES: Self = Self(2);
pub const EADDRINUSE: Self = Self(3);
pub const EADDRNOTAVAIL: Self = Self(4);
pub const EAFNOSUPPORT: Self = Self(5);
pub const EAGAIN: Self = Self(6);
pub const EALREADY: Self = Self(7);
pub const EBADF: Self = Self(8);
pub const EBADMSG: Self = Self(9);
pub const EBUSY: Self = Self(10);
pub const ECANCELED: Self = Self(11);
pub const ECHILD: Self = Self(12);
pub const ECONNABORTED: Self = Self(13);
pub const ECONNREFUSED: Self = Self(14);
pub const ECONNRESET: Self = Self(15);
pub const EDEADLK: Self = Self(16);
pub const EDESTADDRREQ: Self = Self(17);
pub const EDOM: Self = Self(18);
pub const EDQUOT: Self = Self(19);
pub const EEXIST: Self = Self(20);
pub const EFAULT: Self = Self(21);
pub const EFBIG: Self = Self(22);
pub const EHOSTUNREACH: Self = Self(23);
pub const EIDRM: Self = Self(24);
pub const EILSEQ: Self = Self(25);
pub const EINPROGRESS: Self = Self(26);
pub const EINTR: Self = Self(27);
pub const EINVAL: Self = Self(28);
pub const EIO: Self = Self(29);
pub const EISCONN: Self = Self(30);
pub const EISDIR: Self = Self(31);
pub const ELOOP: Self = Self(32);
pub const EMFILE: Self = Self(33);
pub const EMLINK: Self = Self(34);
pub const EMSGSIZE: Self = Self(35);
pub const ENAMETOOLONG: Self = Self(37);
pub const ENETDOWN: Self = Self(38);
pub const ENETRESET: Self = Self(39);
pub const ENETUNREACH: Self = Self(40);
pub const ENFILE: Self = Self(41);
pub const ENOBUFS: Self = Self(42);
pub const ENODEV: Self = Self(44);
pub const ENOENT: Self = Self(45);
pub const ENOEXEC: Self = Self(46);
pub const ENOLCK: Self = Self(47);
pub const ENOMEM: Self = Self(49);
pub const ENOMSG: Self = Self(50);
pub const ENOPROTOOPT: Self = Self(51);
pub const ENOSPC: Self = Self(52);
pub const ENOSYS: Self = Self(55);
pub const ENOTCONN: Self = Self(56);
pub const ENOTDIR: Self = Self(57);
pub const ENOTEMPTY: Self = Self(58);
pub const ENOTSOCK: Self = Self(60);
pub const ENOTSUP: Self = Self(61);
pub const ENOTTY: Self = Self(62);
pub const ENXIO: Self = Self(63);
pub const EOPNOTSUPP: Self = Self(64);
pub const EOVERFLOW: Self = Self(65);
pub const EPERM: Self = Self(67);
pub const EPIPE: Self = Self(68);
pub const EPROTO: Self = Self(69);
pub const EPROTONOSUPPORT: Self = Self(70);
pub const EPROTOTYPE: Self = Self(71);
pub const ERANGE: Self = Self(72);
pub const EROFS: Self = Self(73);
pub const ESPIPE: Self = Self(74);
pub const ESRCH: Self = Self(75);
pub const ESTALE: Self = Self(76);
pub const ETIMEDOUT: Self = Self(78);
pub const ETXTBSY: Self = Self(79);
pub const EWOULDBLOCK: Self = Self(80);
pub const EXDEV: Self = Self(81);
}
impl From<Errno> for RawErrno {
#[inline]
fn from(errno: Errno) -> Self {
errno.0
}
}
impl From<RawErrno> for Errno {
#[inline]
fn from(errno: RawErrno) -> Self {
Self(errno)
}
}
impl From<Errno> for errno::Errno {
#[inline]
fn from(errno: Errno) -> Self {
Self(errno.0)
}
}
impl From<errno::Errno> for Errno {
#[inline]
fn from(errno: errno::Errno) -> Self {
Self(errno.into())
}
}
impl From<Errno> for std::io::Error {
#[inline]
fn from(errno: Errno) -> Self {
std::io::Error::from_raw_os_error(errno.0)
}
}
impl std::fmt::Display for Errno {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::io::Error::from(*self).fmt(f)
}
}
impl std::error::Error for Errno {}
pub type Result<T> = std::result::Result<T, Errno>;