mio/sys/mod.rs
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 methods.
13//! * `tcp` and `udp` modules: see the [`crate::net`] module.
14//! * `Waker`: see [`crate::Waker`].
15
16cfg_os_poll! {
17 macro_rules! debug_detail {
18 (
19 $type: ident ($event_type: ty), $test: path,
20 $($(#[$target: meta])* $libc: ident :: $flag: ident),+ $(,)*
21 ) => {
22 struct $type($event_type);
23
24 impl fmt::Debug for $type {
25 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26 let mut written_one = false;
27 $(
28 $(#[$target])*
29 #[allow(clippy::bad_bit_mask)] // Apparently some flags are zero.
30 {
31 // Windows doesn't use `libc` but the `afd` module.
32 if $test(&self.0, &$libc :: $flag) {
33 if !written_one {
34 write!(f, "{}", stringify!($flag))?;
35 written_one = true;
36 } else {
37 write!(f, "|{}", stringify!($flag))?;
38 }
39 }
40 }
41 )+
42 if !written_one {
43 write!(f, "(empty)")
44 } else {
45 Ok(())
46 }
47 }
48 }
49 };
50 }
51}
52
53#[cfg(any(
54 unix,
55 target_os = "hermit",
56 all(target_os = "wasi", not(target_env = "p1"))
57))]
58cfg_os_poll! {
59 mod unix;
60 #[allow(unused_imports)]
61 pub use self::unix::*;
62}
63
64#[cfg(windows)]
65cfg_os_poll! {
66 mod windows;
67 pub use self::windows::*;
68}
69
70#[cfg(all(target_os = "wasi", target_env = "p1"))]
71cfg_os_poll! {
72 mod wasip1;
73 pub(crate) use self::wasip1::*;
74}
75
76cfg_not_os_poll! {
77 mod shell;
78 pub(crate) use self::shell::*;
79
80 #[cfg(unix)]
81 cfg_any_os_ext! {
82 mod unix;
83 #[cfg(feature = "os-ext")]
84 pub use self::unix::SourceFd;
85 }
86}