Skip to main content

dope_core/io/
mod.rs

1use crate::io::fd::handles;
2pub mod datagram;
3pub mod event;
4pub mod fd;
5pub mod fs;
6pub(crate) mod outputs;
7pub mod recv;
8pub mod socket;
9pub mod transfer;
10
11use event::{batch, net::accept};
12
13use crate::{
14    Errno,
15    driver::{
16        result::{
17            poll,
18            poll::fault::{Echo, Fault},
19        },
20        retained::flight::cancel,
21        route,
22    },
23};
24
25/// A completion emitted by the driver.
26///
27/// [`Event::into_kind`] consumes its exact payload and operation authority.
28/// Safe code cannot mint completion authority.
29///
30///
31///
32#[repr(transparent)]
33pub struct Event<'d>(event::Kind<'d>);
34
35impl<'d> Event<'d> {
36    pub fn into_kind(self) -> event::Kind<'d> {
37        self.0
38    }
39
40    pub fn route(&self) -> route::Route {
41        match &self.0 {
42            event::Kind::Accept(done) => done.token().route(),
43            event::Kind::Recv(done) | event::Kind::RetiredRecv(done) => done.token().route(),
44            event::Kind::Send(done) => done.token().route(),
45            event::Kind::Socket(done) => done.token().route(),
46            event::Kind::Tuning(done) => done.token().route(),
47            event::Kind::Connect(done) => done.token().route(),
48            event::Kind::Open(done) => done.token().route(),
49            event::Kind::Write(done) => done.token().route(),
50            event::Kind::Sync(done) => done.token().route(),
51            event::Kind::Shutdown => route::Route::FRAMEWORK,
52        }
53    }
54}
55
56impl<'d> From<event::Kind<'d>> for Event<'d> {
57    fn from(kind: event::Kind<'d>) -> Self {
58        Self(kind)
59    }
60}
61
62const _: () =
63    assert!(std::mem::size_of::<Event<'static>>() == std::mem::size_of::<event::Kind<'static>>());
64
65/// Cancellation failures retain their operation owners for retry.
66/// Completion reports include buffer return and descriptor retirement outcomes.
67/// Exhausted accepted slots remain quarantined in the native table until reactor teardown.
68#[derive(Debug)]
69pub enum Reclaimed {
70    /// A consumed native completion that violated its operation contract.
71    Fault(Fault),
72    /// A native retirement syscall failed while its exact owner remains retained.
73    Reactor(poll::Cause),
74    /// A cancellation was rejected while its operation owner remains retained.
75    Cancellation(cancel::Failure),
76    Close {
77        slot: handles::PhysicalSlot,
78        file: poll::Close,
79        reactor: Result<(), poll::Cause>,
80    },
81    Accept {
82        echo: Echo,
83        result: Result<handles::Reclaimed, accept::Failure>,
84        flow: batch::Flow,
85    },
86    AcceptRoute {
87        target: route::Token,
88        cause: accept::Failure,
89        flow: batch::Flow,
90    },
91    Recv {
92        echo: Echo,
93        result: Result<usize, Errno>,
94        flow: batch::Flow,
95    },
96    RecvRoute {
97        target: route::Token,
98        result: Result<transfer::Len, Errno>,
99        flow: batch::Flow,
100    },
101    Send {
102        echo: Echo,
103        result: Result<transfer::Len, Errno>,
104    },
105    Connect {
106        echo: Echo,
107        result: Result<(), Errno>,
108    },
109    Socket {
110        echo: Echo,
111        slot: handles::PhysicalSlot,
112        result: Result<(), socket::Create>,
113        close: Option<Result<(), Errno>>,
114    },
115    Open {
116        echo: Echo,
117        result: Result<(), Errno>,
118        close: Option<Result<(), Errno>>,
119    },
120    Write {
121        echo: Echo,
122        result: Result<transfer::Len, Errno>,
123    },
124    Sync {
125        echo: Echo,
126        result: Result<(), Errno>,
127    },
128    Tuning {
129        echo: Echo,
130        result: Result<(), Errno>,
131    },
132    Shutdown,
133}