tpt-torus-core 0.1.0

The Virtual Torus abstraction, Safe API, and Torus handle.
Documentation
/// A single buffer descriptor for vectored I/O (scatter-gather).
#[derive(Debug, Clone, Copy)]
pub struct IoSlice {
    /// Pointer to the buffer.
    pub buf: *mut u8,
    /// Length of the buffer in bytes.
    pub len: usize,
}

/// I/O operations that can be submitted to the Virtual Torus.
///
/// Each variant maps to a native operation on the underlying backend
/// (io_uring opcode on Linux, IOCP on Windows, kqueue on macOS).
#[derive(Debug, Clone)]
pub enum Operation {
    /// Read from a file descriptor at a given offset.
    Read {
        fd: i32,
        buf: *mut u8,
        len: usize,
        offset: u64,
    },
    /// Write to a file descriptor at a given offset.
    Write {
        fd: i32,
        buf: *const u8,
        len: usize,
        offset: u64,
    },
    /// Vectored read (readv) — read from a file descriptor into multiple buffers.
    ///
    /// Maps to `IORING_OP_READV` on Linux, overlapped read on Windows,
    /// and multiple `EVFILT_READ` events on kqueue.
    Readv {
        fd: i32,
        /// Scatter list: each entry is a buffer to read into.
        bufs: *const IoSlice,
        /// Number of entries in `bufs`.
        buf_count: u32,
        offset: u64,
    },
    /// Vectored write (writev) — write multiple buffers to a file descriptor.
    ///
    /// Maps to `IORING_OP_WRITEV` on Linux, overlapped write on Windows,
    /// and multiple `EVFILT_WRITE` events on kqueue.
    Writev {
        fd: i32,
        /// Gather list: each entry is a buffer to write from.
        bufs: *const IoSlice,
        /// Number of entries in `bufs`.
        buf_count: u32,
        offset: u64,
    },
    /// Accept an incoming connection on a listening socket.
    Accept {
        fd: i32,
        addr: *mut libc::sockaddr,
        addrlen: *mut u32,
    },
    /// Connect a socket to a remote address.
    Connect {
        fd: i32,
        addr: *const libc::sockaddr,
        addrlen: u32,
    },
    /// Receive data from a connected socket.
    Recv { fd: i32, buf: *mut u8, len: usize },
    /// Send data to a connected socket.
    Send { fd: i32, buf: *const u8, len: usize },
    /// Close a file descriptor.
    Close { fd: i32 },
}