mio/sys/unix/selector/
stateless_io_source.rs
1use std::io;
4use std::os::fd::RawFd;
5
6use crate::{Interest, Registry, Token};
7
8pub(crate) struct IoSourceState;
9
10impl IoSourceState {
11 pub(crate) fn new() -> IoSourceState {
12 IoSourceState
13 }
14
15 pub(crate) fn do_io<T, F, R>(&self, f: F, io: &T) -> io::Result<R>
16 where
17 F: FnOnce(&T) -> io::Result<R>,
18 {
19 f(io)
22 }
23
24 pub(crate) fn register(
25 &mut self,
26 registry: &Registry,
27 token: Token,
28 interests: Interest,
29 fd: RawFd,
30 ) -> io::Result<()> {
31 registry.selector().register(fd, token, interests)
33 }
34
35 pub(crate) fn reregister(
36 &mut self,
37 registry: &Registry,
38 token: Token,
39 interests: Interest,
40 fd: RawFd,
41 ) -> io::Result<()> {
42 registry.selector().reregister(fd, token, interests)
44 }
45
46 pub(crate) fn deregister(&mut self, registry: &Registry, fd: RawFd) -> io::Result<()> {
47 registry.selector().deregister(fd)
49 }
50}