azur 0.3.1

A no_std Rust crate that implements an executor/reactor and futures using io_uring
Documentation
use super::Op;
use crate::future::Future;

pub struct Accept {
    fd: lx::RawFd,
    flags: i32,
}

unsafe impl Op for Accept {
    type Output = lx::Result<lx::OwnedFd>;

    fn fill_sqe(&mut self, sqe: &mut lx::io_uring_sqe) {
        sqe.opcode = lx::IORING_OP_ACCEPT;
        sqe.fd = self.fd;
        sqe.op_flags = self.flags as u32;
    }

    fn complete(self, ret: i32) -> Self::Output {
        if let Ok(err) = lx::Error::try_from(ret) {
            Err(err)
        } else {
            Ok(lx::OwnedFd::new(ret))
        }
    }
}

pub fn accept(fd: &impl lx::AsRawFd, flags: i32) -> Future<Accept> {
    Future::new(Accept {
        fd: fd.as_raw_fd(),
        flags,
    })
}