Debian Codegraph @

third_party/rust/mio/src/sys/shell/mod.rs

raw
1 macro_rules! os_required {
2 () => {
3 panic!("mio must be compiled with `os-poll` to run.")
4 };
5 }
6
7 mod selector;
8 pub(crate) use self::selector::{event, Event, Events, Selector};
9
10 #[cfg(not(target_os = "wasi"))]
11 mod waker;
12 #[cfg(not(target_os = "wasi"))]
13 pub(crate) use self::waker::Waker;
14
15 cfg_net! {
16 pub(crate) mod tcp;
17 pub(crate) mod udp;
18 #[cfg(unix)]
19 pub(crate) mod uds;
20 }
21
22 cfg_io_source! {
23 use std::io;
24 #[cfg(any(unix))]
25 use std::os::fd::RawFd;
26 // TODO: once <https://github.com/rust-lang/rust/issues/126198> is fixed this
27 // can use `std::os::fd` and be merged with the above.
28 #[cfg(target_os = "hermit")]
29 use std::os::hermit::io::RawFd;
30 #[cfg(windows)]
31 use std::os::windows::io::RawSocket;
32
33 #[cfg(any(windows, unix, target_os = "hermit"))]
34 use crate::{Registry, Token, Interest};
35
36 pub(crate) struct IoSourceState;
37
38 impl IoSourceState {
39 pub fn new() -> IoSourceState {
40 IoSourceState
41 }
42
43 pub fn do_io<T, F, R>(&self, f: F, io: &T) -> io::Result<R>
44 where
45 F: FnOnce(&T) -> io::Result<R>,
46 {
47 // We don't hold state, so we can just call the function and
48 // return.
49 f(io)
50 }
51 }
52
53 #[cfg(any(unix, target_os = "hermit"))]
54 impl IoSourceState {
55 pub fn register(
56 &mut self,
57 _: &Registry,
58 _: Token,
59 _: Interest,
60 _: RawFd,
61 ) -> io::Result<()> {
62 os_required!()
63 }
64
65 pub fn reregister(
66 &mut self,
67 _: &Registry,
68 _: Token,
69 _: Interest,
70 _: RawFd,
71 ) -> io::Result<()> {
72 os_required!()
73 }
74
75 pub fn deregister(&mut self, _: &Registry, _: RawFd) -> io::Result<()> {
76 os_required!()
77 }
78 }
79
80 #[cfg(windows)]
81 impl IoSourceState {
82 pub fn register(
83 &mut self,
84 _: &Registry,
85 _: Token,
86 _: Interest,
87 _: RawSocket,
88 ) -> io::Result<()> {
89 os_required!()
90 }
91
92 pub fn reregister(
93 &mut self,
94 _: &Registry,
95 _: Token,
96 _: Interest,
97 ) -> io::Result<()> {
98 os_required!()
99 }
100
101 pub fn deregister(&mut self) -> io::Result<()> {
102 os_required!()
103 }
104 }
105 }