oscall 0.1.1

Low-level cross-platform interface to operating system services: files, memory mapping, networking and more, with no libc on Linux
Documentation
//! WebAssembly without a system interface (`wasm32-unknown-unknown`): there
//! is no operating system to call. Every portable function exists and fails
//! with `Unsupported`, except the few that need no system at all.
//!
//! Error codes are WASI's, so that the two WebAssembly targets agree.

#[path = "../wasi/errno.rs"]
pub(crate) mod errno;

pub(crate) mod env;
pub(crate) mod event;
pub(crate) mod fs;
pub(crate) mod io;
pub(crate) mod mem;
pub(crate) mod net;
pub(crate) mod process;
pub(crate) mod rand;
pub(crate) mod resolve;
pub(crate) mod sync;
pub(crate) mod thread;
pub(crate) mod time;

use crate::ErrorKind;

pub(crate) type RawHandle = i32;

/// # Safety
///
/// None: there are no handles to close.
pub(crate) unsafe fn close(_fd: RawHandle) {}

/// The generic I/O error.
pub(crate) const OTHER_ERROR: i32 = errno::EIO;

/// The classification of error codes. The first entry of a kind is the code
/// `Error::from(kind)` produces.
pub(crate) const ERRORS: &[(i32, ErrorKind)] = {
    use ErrorKind::*;
    use errno::*;
    &[
        (ENOENT, NotFound),
        (EACCES, PermissionDenied),
        (EPERM, PermissionDenied),
        (ENOTCAPABLE, PermissionDenied),
        (EEXIST, AlreadyExists),
        (EAGAIN, WouldBlock),
        (EINPROGRESS, InProgress),
        (EALREADY, InProgress),
        (EINTR, Interrupted),
        (EINVAL, InvalidInput),
        (ETIMEDOUT, TimedOut),
        (ENOTSUP, Unsupported),
        (ENOSYS, Unsupported),
        (EAFNOSUPPORT, Unsupported),
        (EPROTONOSUPPORT, Unsupported),
        (ENOMEM, OutOfMemory),
        (EBADF, BadHandle),
        (ENOTSOCK, BadHandle),
        (EPIPE, BrokenPipe),
        (ENOTDIR, NotADirectory),
        (EISDIR, IsADirectory),
        (ENOTEMPTY, DirectoryNotEmpty),
        (ENAMETOOLONG, InvalidFilename),
        (ERANGE, BufferTooSmall),
        (ELOOP, FilesystemLoop),
        (ENOSPC, StorageFull),
        (EDQUOT, QuotaExceeded),
        (EFBIG, FileTooLarge),
        (EROFS, ReadOnlyFilesystem),
        (EXDEV, CrossesDevices),
        (EMLINK, TooManyLinks),
        (EMFILE, TooManyOpenFiles),
        (ENFILE, TooManyOpenFiles),
        (EBUSY, ResourceBusy),
        (EDEADLK, Deadlock),
        (ESPIPE, NotSeekable),
        (ETXTBSY, ExecutableFileBusy),
        (ECONNREFUSED, ConnectionRefused),
        (ECONNRESET, ConnectionReset),
        (ECONNABORTED, ConnectionAborted),
        (ENOTCONN, NotConnected),
        (EISCONN, AlreadyConnected),
        (EADDRINUSE, AddrInUse),
        (EADDRNOTAVAIL, AddrNotAvailable),
        (ENETDOWN, NetworkDown),
        (ENETUNREACH, NetworkUnreachable),
        (EHOSTUNREACH, HostUnreachable),
        (EMSGSIZE, MessageTooLong),
        (ESRCH, NoSuchProcess),
        (ECANCELED, Canceled),
    ]
};