dope_sys/io/socket/option/tuning/device/
mod.rs1pub mod raw;
2
3use o3::depot::capacity;
4
5use crate::{
6 Errno,
7 io::socket::{option, option::tuning::Error},
8};
9
10pub trait Source {
12 type Socket<H>: Owner<H>;
13}
14
15pub trait Owner<H>: Sized {
17 fn new(host: H) -> Self;
18}
19
20pub 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
27pub 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#[derive(Debug)]
47pub enum Finish<F, R, P> {
48 Applied(F),
49 Pending(F, R, P),
50}
51
52#[derive(Debug)]
54pub enum Failure<F, E> {
55 Option(F, Errno),
56 Reserve(Error<F, E>),
57}
58
59pub 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}