Skip to main content

dope_sys/io/socket/option/tuning/device/
mod.rs

1pub mod raw;
2
3use o3::depot::capacity;
4
5use crate::{
6    Errno,
7    io::socket::{option, option::tuning::Error},
8};
9
10/// Selects the native owner for one affine socket operation.
11pub trait Source {
12    type Socket<H>: Owner<H>;
13}
14
15/// Owns the host's descriptor, route and exclusive backend access until settlement.
16pub trait Owner<H>: Sized {
17    fn new(host: H) -> Self;
18}
19
20/// Retains one nonempty option set until its exact native chain is selected.
21pub trait Options<const N: usize>: Into<Self::Cursor> {
22    type Cursor: option::Cursor;
23
24    fn split(self) -> (capacity::Limit<N>, Self::Cursor);
25}
26
27/// Defers a typed flight reservation until native queue capacity is retained.
28pub trait Reserve {
29    type Key: Copy;
30    type Vacant;
31    type Reservation;
32    type Error;
33
34    fn try_vacancy(self) -> Result<Self::Vacant, Self::Error>;
35    fn reserve(vacant: Self::Vacant) -> (Self::Key, Self::Reservation);
36
37    fn try_reserve(self) -> Result<(Self::Key, Self::Reservation), Self::Error>
38    where
39        Self: Sized,
40    {
41        Ok(Self::reserve(self.try_vacancy()?))
42    }
43}
44
45/// The descriptor is returned with the exact native cancellation authority.
46#[derive(Debug)]
47pub enum Finish<F, R, P> {
48    Applied(F),
49    Pending(F, R, P),
50}
51
52/// Native option failures retain the rejected descriptor and exact failed stage.
53#[derive(Debug)]
54pub enum Failure<F, E> {
55    Option(F, Errno),
56    Reserve(Error<F, E>),
57}
58
59/// One descriptor's admitted slot in its exact exclusively borrowed backend.
60///
61/// Only an unsafe host's root callback can create this owner; consuming it is
62/// the only way to separate its descriptor from the backend and native target.
63pub struct Admission<'a, B, F, S, I> {
64    backend: &'a mut B,
65    file: F,
66    slot: S,
67    index: I,
68}
69
70impl<'a, B, F, S, I> Admission<'a, B, F, S, I> {
71    pub fn into_parts(self) -> (&'a mut B, F, S, I) {
72        (self.backend, self.file, self.slot, self.index)
73    }
74
75    pub fn into_file(self) -> F {
76        self.file
77    }
78}