#![cfg_attr(feature = "cargo-clippy", allow(unreadable_literal))]
use std;
use phf;
use ErrnoCode;
use ErrnoCodes;
pub fn info_by_num(errnum: std::os::raw::c_int) -> Option<&'static ErrnoCode> {
BY_NUM.get(&errnum).map(|infos| &infos[0])
}
pub fn info_by_id(err_id: &str) -> Option<&'static ErrnoCode> {
BY_ID.get(err_id)
}
pub fn strerror(errnum: std::os::raw::c_int) -> Option<&'static str> {
info_by_num(errnum).map(|info| info.msg)
}
pub const EPERM: std::os::raw::c_int = 1;
pub const EPERM_MSG: &str = "Operation not permitted";
pub const EPERM_ID: &str = "EPERM";
pub const ENOFILE: std::os::raw::c_int = 2;
pub const ENOFILE_MSG: &str = "No such file or directory";
pub const ENOFILE_ID: &str = "ENOFILE";
pub const ENOENT: std::os::raw::c_int = 2;
pub const ENOENT_MSG: &str = "Same as ENOFILE (No such file or directory)";
pub const ENOENT_ID: &str = "ENOENT";
pub const ESRCH: std::os::raw::c_int = 3;
pub const ESRCH_MSG: &str = "No such process";
pub const ESRCH_ID: &str = "ESRCH";
pub const EINTR: std::os::raw::c_int = 4;
pub const EINTR_MSG: &str = "Interrupted function call";
pub const EINTR_ID: &str = "EINTR";
pub const EIO: std::os::raw::c_int = 5;
pub const EIO_MSG: &str = "Input/output error";
pub const EIO_ID: &str = "EIO";
pub const ENXIO: std::os::raw::c_int = 6;
pub const ENXIO_MSG: &str = "No such device or address";
pub const ENXIO_ID: &str = "ENXIO";
pub const E2BIG: std::os::raw::c_int = 7;
pub const E2BIG_MSG: &str = "Arg list too long";
pub const E2BIG_ID: &str = "E2BIG";
pub const ENOEXEC: std::os::raw::c_int = 8;
pub const ENOEXEC_MSG: &str = "Exec format error";
pub const ENOEXEC_ID: &str = "ENOEXEC";
pub const EBADF: std::os::raw::c_int = 9;
pub const EBADF_MSG: &str = "Bad file descriptor";
pub const EBADF_ID: &str = "EBADF";
pub const ECHILD: std::os::raw::c_int = 10;
pub const ECHILD_MSG: &str = "No child processes";
pub const ECHILD_ID: &str = "ECHILD";
pub const EAGAIN: std::os::raw::c_int = 11;
pub const EAGAIN_MSG: &str = "Resource temporarily unavailable";
pub const EAGAIN_ID: &str = "EAGAIN";
pub const ENOMEM: std::os::raw::c_int = 12;
pub const ENOMEM_MSG: &str = "Not enough space";
pub const ENOMEM_ID: &str = "ENOMEM";
pub const EACCES: std::os::raw::c_int = 13;
pub const EACCES_MSG: &str = "Permission denied";
pub const EACCES_ID: &str = "EACCES";
pub const EFAULT: std::os::raw::c_int = 14;
pub const EFAULT_MSG: &str = "Bad address";
pub const EFAULT_ID: &str = "EFAULT";
pub const EBUSY: std::os::raw::c_int = 16;
pub const EBUSY_MSG: &str = "strerror reports \"Resource device\"";
pub const EBUSY_ID: &str = "EBUSY";
pub const EEXIST: std::os::raw::c_int = 17;
pub const EEXIST_MSG: &str = "File exists";
pub const EEXIST_ID: &str = "EEXIST";
pub const EXDEV: std::os::raw::c_int = 18;
pub const EXDEV_MSG: &str = "Improper link (cross-device link?)";
pub const EXDEV_ID: &str = "EXDEV";
pub const ENODEV: std::os::raw::c_int = 19;
pub const ENODEV_MSG: &str = "No such device";
pub const ENODEV_ID: &str = "ENODEV";
pub const ENOTDIR: std::os::raw::c_int = 20;
pub const ENOTDIR_MSG: &str = "Not a directory";
pub const ENOTDIR_ID: &str = "ENOTDIR";
pub const EISDIR: std::os::raw::c_int = 21;
pub const EISDIR_MSG: &str = "Is a directory";
pub const EISDIR_ID: &str = "EISDIR";
pub const EINVAL: std::os::raw::c_int = 22;
pub const EINVAL_MSG: &str = "Invalid argument";
pub const EINVAL_ID: &str = "EINVAL";
pub const ENFILE: std::os::raw::c_int = 23;
pub const ENFILE_MSG: &str = "Too many open files in system";
pub const ENFILE_ID: &str = "ENFILE";
pub const EMFILE: std::os::raw::c_int = 24;
pub const EMFILE_MSG: &str = "Too many open files";
pub const EMFILE_ID: &str = "EMFILE";
pub const ENOTTY: std::os::raw::c_int = 25;
pub const ENOTTY_MSG: &str = "Inappropriate I/O control operation";
pub const ENOTTY_ID: &str = "ENOTTY";
pub const EFBIG: std::os::raw::c_int = 27;
pub const EFBIG_MSG: &str = "File too large";
pub const EFBIG_ID: &str = "EFBIG";
pub const ENOSPC: std::os::raw::c_int = 28;
pub const ENOSPC_MSG: &str = "No space left on device";
pub const ENOSPC_ID: &str = "ENOSPC";
pub const ESPIPE: std::os::raw::c_int = 29;
pub const ESPIPE_MSG: &str = "Invalid seek (seek on a pipe?)";
pub const ESPIPE_ID: &str = "ESPIPE";
pub const EROFS: std::os::raw::c_int = 30;
pub const EROFS_MSG: &str = "Read-only file system";
pub const EROFS_ID: &str = "EROFS";
pub const EMLINK: std::os::raw::c_int = 31;
pub const EMLINK_MSG: &str = "Too many links";
pub const EMLINK_ID: &str = "EMLINK";
pub const EPIPE: std::os::raw::c_int = 32;
pub const EPIPE_MSG: &str = "Broken pipe";
pub const EPIPE_ID: &str = "EPIPE";
pub const EDOM: std::os::raw::c_int = 33;
pub const EDOM_MSG: &str = "Domain error (math functions)";
pub const EDOM_ID: &str = "EDOM";
pub const ERANGE: std::os::raw::c_int = 34;
pub const ERANGE_MSG: &str = "Result too large (possibly too small)";
pub const ERANGE_ID: &str = "ERANGE";
pub const EDEADLOCK: std::os::raw::c_int = 36;
pub const EDEADLOCK_MSG: &str = "Resource deadlock avoided (non-Cyg)";
pub const EDEADLOCK_ID: &str = "EDEADLOCK";
pub const EDEADLK: std::os::raw::c_int = 36;
pub const EDEADLK_MSG: &str = "Same as EDEADLOCK (Resource deadlock avoided (non-Cyg))";
pub const EDEADLK_ID: &str = "EDEADLK";
pub const ENAMETOOLONG: std::os::raw::c_int = 38;
pub const ENAMETOOLONG_MSG: &str = "Filename too long (91 in Cyg?)";
pub const ENAMETOOLONG_ID: &str = "ENAMETOOLONG";
pub const ENOLCK: std::os::raw::c_int = 39;
pub const ENOLCK_MSG: &str = "No locks available (46 in Cyg?)";
pub const ENOLCK_ID: &str = "ENOLCK";
pub const ENOSYS: std::os::raw::c_int = 40;
pub const ENOSYS_MSG: &str = "Function not implemented (88 in Cyg?)";
pub const ENOSYS_ID: &str = "ENOSYS";
pub const ENOTEMPTY: std::os::raw::c_int = 41;
pub const ENOTEMPTY_MSG: &str = "Directory not empty (90 in Cyg?)";
pub const ENOTEMPTY_ID: &str = "ENOTEMPTY";
pub const EILSEQ: std::os::raw::c_int = 42;
pub const EILSEQ_MSG: &str = "Illegal byte sequence";
pub const EILSEQ_ID: &str = "EILSEQ";
include!(concat!(env!("OUT_DIR"), "/windows.rs"));
#[cfg(test)]
mod tests {
use ErrnoCode;
#[test]
fn info_by_num() {
assert_eq!(
super::info_by_num(super::EDOM),
Some(&ErrnoCode {
num: super::EDOM,
msg: super::EDOM_MSG,
id: super::EDOM_ID,
})
);
}
#[test]
fn info_by_id() {
assert_eq!(
super::info_by_id(super::EDOM_ID),
Some(&ErrnoCode {
num: super::EDOM,
msg: super::EDOM_MSG,
id: super::EDOM_ID,
})
);
}
#[test]
fn strerror() {
assert_eq!(super::strerror(super::EDOM), Some(super::EDOM_MSG));
assert_eq!(super::strerror(0), None);
}
}