| 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 (any(unix, target_os = "hermit" ))] |
| 55 | cfg_os_poll! { |
| 56 | mod unix; |
| 57 | #[allow (unused_imports)] |
| 58 | pub use self::unix::*; |
| 59 | } |
| 60 | |
| 61 | #[cfg (windows)] |
| 62 | cfg_os_poll! { |
| 63 | mod windows; |
| 64 | pub use self::windows::*; |
| 65 | } |
| 66 | |
| 67 | #[cfg (target_os = "wasi" )] |
| 68 | cfg_os_poll! { |
| 69 | mod wasi; |
| 70 | pub(crate) use self::wasi::*; |
| 71 | } |
| 72 | |
| 73 | cfg_not_os_poll! { |
| 74 | mod shell; |
| 75 | pub(crate) use self::shell::*; |
| 76 | |
| 77 | #[cfg (unix)] |
| 78 | cfg_any_os_ext! { |
| 79 | mod unix; |
| 80 | #[cfg(feature = "os-ext" )] |
| 81 | pub use self::unix::SourceFd; |
| 82 | } |
| 83 | } |
| 84 | |