pub mod raw;
use o3::depot::capacity;
use crate::{
Errno,
io::socket::{option, option::tuning::Error},
};
pub trait Source {
type Socket<H>: Owner<H>;
}
pub trait Owner<H>: Sized {
fn new(host: H) -> Self;
}
pub trait Options<const N: usize>: Into<Self::Cursor> {
type Cursor: option::Cursor;
fn split(self) -> (capacity::Limit<N>, Self::Cursor);
}
pub trait Reserve {
type Key: Copy;
type Vacant;
type Reservation;
type Error;
fn try_vacancy(self) -> Result<Self::Vacant, Self::Error>;
fn reserve(vacant: Self::Vacant) -> (Self::Key, Self::Reservation);
fn try_reserve(self) -> Result<(Self::Key, Self::Reservation), Self::Error>
where
Self: Sized,
{
Ok(Self::reserve(self.try_vacancy()?))
}
}
#[derive(Debug)]
pub enum Finish<F, R, P> {
Applied(F),
Pending(F, R, P),
}
#[derive(Debug)]
pub enum Failure<F, E> {
Option(F, Errno),
Reserve(Error<F, E>),
}
pub struct Admission<'a, B, F, S, I> {
backend: &'a mut B,
file: F,
slot: S,
index: I,
}
impl<'a, B, F, S, I> Admission<'a, B, F, S, I> {
pub fn into_parts(self) -> (&'a mut B, F, S, I) {
(self.backend, self.file, self.slot, self.index)
}
pub fn into_file(self) -> F {
self.file
}
}