dope-uring 0.75.0

Owned io_uring backend for dope
Documentation
use std::{marker, mem, num, pin, ptr};

use dope_sys::io::socket::option::tuning;

use crate::driver::tuning::{Occupied, State};

// SAFETY: projection never moves the values, and only the consumed terminal
// owner can clear the echo that marks their linked chain occupied.
unsafe impl<E: Copy, const N: usize> tuning::raw::State<E, N> for State<E, N> {
    type Occupied<'a>
        = Occupied<'a, E, N>
    where
        Self: 'a;

    fn bind(self: pin::Pin<&mut Self>) -> Option<Self::Occupied<'_>> {
        const {
            assert!(
                mem::size_of::<Occupied<'_, E, N>>() == mem::size_of::<(pin::Pin<&mut Self>, E)>()
            );
            assert!(
                mem::align_of::<Occupied<'_, E, N>>()
                    == mem::align_of::<(pin::Pin<&mut Self>, E)>()
            );
        };
        let target = self.as_ref().target?;
        Some(Occupied {
            state: ptr::NonNull::from(unsafe { self.get_unchecked_mut() }),
            target,
            loan: marker::PhantomData,
        })
    }

    unsafe fn values(
        self: pin::Pin<&mut Self>,
        target: E,
        count: num::NonZero<u32>,
    ) -> &mut [libc::c_int; N] {
        // SAFETY: the caller proves this exact option count and retains the
        // pinned owner until every corresponding native CQE has arrived.
        unsafe { self.begin(target, count, None) }
    }
}