1 | //! Module with system specific types. |
2 | //! |
3 | //! Required types: |
4 | //! |
5 | //! * `Event`: a type alias for the system specific event, e.g. `kevent` or |
6 | //! `epoll_event`. |
7 | //! * `event`: a module with various helper functions for `Event`, see |
8 | //! [`crate::event::Event`] for the required functions. |
9 | //! * `Events`: collection of `Event`s, see [`crate::Events`]. |
10 | //! * `IoSourceState`: state for the `IoSource` type. |
11 | //! * `Selector`: selector used to register event sources and poll for events, |
12 | //! see [`crate::Poll`] and [`crate::Registry`] for required |
13 | //! methods. |
14 | //! * `tcp` and `udp` modules: see the [`crate::net`] module. |
15 | //! * `Waker`: see [`crate::Waker`]. |
16 | |
17 | cfg_os_poll! { |
18 | macro_rules! debug_detail { |
19 | ( |
20 | $type: ident ($event_type: ty), $test: path, |
21 | $($(#[$target: meta])* $libc: ident :: $flag: ident),+ $(,)* |
22 | ) => { |
23 | struct $type($event_type); |
24 | |
25 | impl fmt::Debug for $type { |
26 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
27 | let mut written_one = false; |
28 | $( |
29 | $(#[$target])* |
30 | #[allow(clippy::bad_bit_mask)] // Apparently some flags are zero. |
31 | { |
32 | // Windows doesn't use `libc` but the `afd` module. |
33 | if $test(&self.0, &$libc :: $flag) { |
34 | if !written_one { |
35 | write!(f, "{}" , stringify!($flag))?; |
36 | written_one = true; |
37 | } else { |
38 | write!(f, "|{}" , stringify!($flag))?; |
39 | } |
40 | } |
41 | } |
42 | )+ |
43 | if !written_one { |
44 | write!(f, "(empty)" ) |
45 | } else { |
46 | Ok(()) |
47 | } |
48 | } |
49 | } |
50 | }; |
51 | } |
52 | } |
53 | |
54 | #[cfg (unix)] |
55 | cfg_os_poll! { |
56 | mod unix; |
57 | pub use self::unix::*; |
58 | } |
59 | |
60 | #[cfg (windows)] |
61 | cfg_os_poll! { |
62 | mod windows; |
63 | pub use self::windows::*; |
64 | } |
65 | |
66 | #[cfg (target_os = "wasi" )] |
67 | cfg_os_poll! { |
68 | mod wasi; |
69 | pub(crate) use self::wasi::*; |
70 | } |
71 | |
72 | cfg_not_os_poll! { |
73 | mod shell; |
74 | pub(crate) use self::shell::*; |
75 | |
76 | #[cfg (unix)] |
77 | cfg_any_os_ext! { |
78 | mod unix; |
79 | pub use self::unix::SourceFd; |
80 | } |
81 | |
82 | #[cfg (unix)] |
83 | cfg_net! { |
84 | pub use self::unix::SocketAddr; |
85 | } |
86 | } |
87 | |