dope-core 0.75.0

Owned native I/O and completion driver for dope
Documentation
use std::marker;

use dope_sys::io::{reactor::ready::delivery::entry, socket::Prepare};

use crate::{
    driver::{life::native::host::poll::files, retained::flight},
    io::{
        event::{batch::Flow, net::accept},
        fd::handles::OutboundSlot,
    },
};

#[derive(Clone, Copy, Debug)]
pub(crate) struct Context<N>(marker::PhantomData<N>);

impl<N: Prepare> entry::Context for Context<N> {
    type Reader = files::Slots;
    type Writer = files::Slots;
    type Outbound = OutboundSlot;
    type Handle = N::Handle;
    type Failure = accept::Failure;

    const LAST: Flow = Flow::Last;
    const MORE: Flow = Flow::More;
}

#[derive(Clone, Copy, Debug)]
pub(crate) enum Udata {
    Public(flight::raw::Echo),
    Shutdown(dope_sys::engine::register::Interest),
}

impl From<Udata> for usize {
    fn from(data: Udata) -> Self {
        const { assert!(flight::raw::Echo::BITS < usize::BITS) };
        match data {
            Udata::Public(key) => u64::from(key) as usize,
            Udata::Shutdown(dope_sys::engine::register::Interest::Readable) => usize::MAX,
            Udata::Shutdown(dope_sys::engine::register::Interest::Closed) => usize::MAX - 1,
        }
    }
}

impl From<flight::raw::Echo> for Udata {
    fn from(key: flight::raw::Echo) -> Self {
        Self::Public(key)
    }
}