• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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(windows)]
25     use std::os::windows::io::RawSocket;
26 
27     #[cfg(windows)]
28     use crate::{Registry, Token, Interest};
29 
30     pub(crate) struct IoSourceState;
31 
32     impl IoSourceState {
33         pub fn new() -> IoSourceState {
34             IoSourceState
35         }
36 
37         pub fn do_io<T, F, R>(&self, f: F, io: &T) -> io::Result<R>
38         where
39             F: FnOnce(&T) -> io::Result<R>,
40         {
41             // We don't hold state, so we can just call the function and
42             // return.
43             f(io)
44         }
45     }
46 
47     #[cfg(windows)]
48     impl IoSourceState {
49          pub fn register(
50             &mut self,
51             _: &Registry,
52             _: Token,
53             _: Interest,
54             _: RawSocket,
55         ) -> io::Result<()> {
56             os_required!()
57         }
58 
59         pub fn reregister(
60             &mut self,
61             _: &Registry,
62             _: Token,
63             _: Interest,
64         ) -> io::Result<()> {
65            os_required!()
66         }
67 
68         pub fn deregister(&mut self) -> io::Result<()> {
69             os_required!()
70         }
71     }
72 }
73