azur 0.3.1

A no_std Rust crate that implements an executor/reactor and futures using io_uring
Documentation
mod array;
mod ptr;

use alloc::{
    string::String,
    vec::Vec,
};
use core::mem::MaybeUninit;

pub use array::ArrayBuf;
pub use ptr::{
    PtrBuf,
    PtrBufMut,
};

/// A buffer suitable for use in write-like operations.
///
/// # Safety
///
/// The memory that the buffer refers to must not be deallocated before the buffer is dropped.
pub unsafe trait IoBuf: AsRef<[u8]> {}

/// A buffer suitable for use in read-like operations.
///
/// # Safety
///
/// The memory that the buffer refers to must not be deallocated before the buffer is dropped.
pub unsafe trait IoBufMut: IoBuf {
    fn uninit_bytes(&mut self) -> &mut [MaybeUninit<u8>];

    /// Sets the length of the buffer.
    ///
    /// # Safety
    ///
    /// The caller must ensure that bytes `0..new_len` were initialized.
    unsafe fn set_len(&mut self, new_len: usize);
}

unsafe impl IoBuf for &'static [u8] {}

unsafe impl IoBuf for &'static str {}

unsafe impl<const N: usize> IoBuf for [u8; N] {}

unsafe impl<const N: usize> IoBuf for &'static [u8; N] {}

unsafe impl IoBuf for Vec<u8> {}

unsafe impl IoBufMut for Vec<u8> {
    fn uninit_bytes(&mut self) -> &mut [MaybeUninit<u8>] {
        unsafe {
            core::slice::from_raw_parts_mut(
                self.as_mut_ptr() as *mut MaybeUninit<u8>,
                self.capacity(),
            )
        }
    }

    unsafe fn set_len(&mut self, new_len: usize) {
        self.set_len(new_len);
    }
}

unsafe impl IoBuf for String {}

unsafe impl IoBuf for lx::Mmap {}