use std::marker;
use dope_sys::{
engine::register::Interest,
io::{
reactor::{complete::flags::Flow, ready::delivery::entry},
socket::Prepare,
},
};
use crate::{
driver::{life::native::host::poll::files, retained::flight},
io::{event::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::Echo),
Shutdown(Interest),
}
impl From<Udata> for usize {
fn from(data: Udata) -> Self {
const { assert!(flight::Echo::BITS < usize::BITS) };
match data {
Udata::Public(key) => u64::from(key) as usize,
Udata::Shutdown(Interest::Readable) => usize::MAX,
Udata::Shutdown(Interest::Closed) => usize::MAX - 1,
}
}
}
impl From<flight::Echo> for Udata {
fn from(key: flight::Echo) -> Self {
Self::Public(key)
}
}