Skip to main content

dope_core/driver/result/poll/
mod.rs

1use std::{mem, os::fd, task};
2
3/// Descriptor readiness direction whose native change could not be committed.
4pub use dope_sys::table::change::Filter;
5
6use crate::driver::route::{indices, table::bounds};
7
8mod cause;
9mod dispatch;
10mod error;
11pub mod fault;
12
13pub use cause::Cause;
14pub use dispatch::{Dispatch, Failure};
15pub use error::Error;
16
17/// Exact reactor operation that failed on a readiness-queue backend.
18#[derive(Clone, Copy, Eq, PartialEq, Debug)]
19pub enum Operation {
20    Wait,
21    Changes,
22    Accept,
23    Connect,
24    SocketError,
25    Recv,
26    RecvMsg,
27    Send,
28    Shutdown,
29    FileOpen,
30    FileWrite,
31    FileSync,
32    FileRename,
33    FileUnlink,
34}
35
36/// Exact descriptor-table absence observed by a readiness backend.
37#[derive(Clone, Copy, Eq, PartialEq, Debug)]
38#[repr(u8)]
39pub enum Missing {
40    Bounds(bounds::Excluded),
41    Backing {
42        index: indices::SlotIndex,
43    },
44    Vacant {
45        index: indices::SlotIndex,
46    },
47    Replaced {
48        index: indices::SlotIndex,
49        expected: fd::RawFd,
50        actual: fd::RawFd,
51    },
52}
53
54#[derive(Clone, Copy, Eq, PartialEq, Debug)]
55#[must_use = "pending backend events must be drained before blocking"]
56pub enum Drain {
57    /// The backend's visible event queue was empty after synchronization.
58    Drained,
59    /// Visible events remain and require another reactor turn.
60    Pending,
61}
62
63impl From<task::Poll<()>> for Drain {
64    fn from(state: task::Poll<()>) -> Self {
65        match state {
66            task::Poll::Ready(()) => Self::Drained,
67            task::Poll::Pending => Self::Pending,
68        }
69    }
70}
71
72/// Backend publication progress, not completion of submitted I/O.
73#[derive(Clone, Copy, Eq, PartialEq)]
74#[must_use = "pending backend changes must be committed in a later reactor turn"]
75pub enum Commit {
76    /// Every change queued before this call has reached the backend.
77    Drained,
78    /// Queued changes remain and require another reactor turn.
79    Pending,
80}
81
82const _: () = {
83    assert!(mem::size_of::<Missing>() == 4 * mem::size_of::<u32>());
84    assert!(mem::align_of::<Missing>() == mem::align_of::<u32>());
85    assert!(mem::size_of::<Operation>() == 1);
86    assert!(core::mem::size_of::<Result<(), Error>>() == core::mem::size_of::<Error>());
87    assert!(core::mem::size_of::<Result<Commit, Error>>() == core::mem::size_of::<Error>());
88};
89
90/// Descriptor retirement distinguishes missing ownership from the exact close result.
91#[derive(Clone, Copy, Debug, Eq, PartialEq)]
92pub enum Close {
93    Missing(Missing),
94    Closed(Result<(), crate::Errno>),
95}