Skip to main content

dope_sys/io/reactor/ready/
mod.rs

1use std::time;
2
3use crate::{
4    Errno,
5    table::change::{Filter, Index},
6};
7
8mod backend;
9pub mod delivery;
10mod driver;
11mod poll;
12pub mod raw;
13mod source;
14pub mod store;
15
16pub use backend::Backend;
17pub use driver::Driver;
18pub use poll::Poll;
19pub use source::Source;
20
21/// Readiness failures classified at the syscall or timeout validation boundary.
22#[derive(Clone, Copy, Debug, Eq, PartialEq)]
23pub enum Cause {
24    Timeout(time::Duration),
25    Wait(Errno),
26    Changes(Errno),
27}
28
29/// One syscall's bounded receipt storage, shared by its native input and output.
30pub const RECEIPTS: usize = 64;
31
32/// Every failure issued by one retirement attempt, in receipt order.
33#[derive(Debug)]
34pub struct Failures<F> {
35    pub first: F,
36    pub rest: [Option<F>; RECEIPTS - 1],
37}
38
39impl<F> From<F> for Failures<F> {
40    fn from(first: F) -> Self {
41        Self {
42            first,
43            rest: [const { None }; RECEIPTS - 1],
44        }
45    }
46}
47
48/// Exact readiness failure constructors retaining the caller's typed domains.
49pub trait Failure: Copy + From<Cause> {
50    type Index: Copy + Eq;
51    type Missing: Copy + Eq;
52    type Operation: Copy;
53
54    fn revoke(fd: usize, filter: Filter, errno: Errno) -> Self;
55    fn backing(error: Index<Self::Index>) -> Self;
56    fn missing(op: Self::Operation, cause: Self::Missing) -> Self;
57    fn system(op: Self::Operation, errno: Errno) -> Self;
58}