compio_driver/
driver_type.rs1#[repr(u8)]
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4pub enum DriverType {
5 Poll,
7 IoUring,
9 IOCP,
11}
12
13impl DriverType {
14 #[cfg(fusion)]
16 pub(crate) fn suggest() -> DriverType {
17 use io_uring::opcode::*;
18
19 const USED_OP: &[u8] = &[
21 Read::CODE,
22 Readv::CODE,
23 Write::CODE,
24 Writev::CODE,
25 Fsync::CODE,
26 Accept::CODE,
27 Connect::CODE,
28 Recv::CODE,
29 Send::CODE,
30 RecvMsg::CODE,
31 SendMsg::CODE,
32 AsyncCancel::CODE,
33 OpenAt::CODE,
34 Close::CODE,
35 Splice::CODE,
36 Shutdown::CODE,
37 ];
38
39 if USED_OP.iter().all(|op| crate::sys::is_op_supported(*op)) {
40 DriverType::IoUring
41 } else {
42 DriverType::Poll
43 }
44 }
45
46 pub fn is_polling(&self) -> bool {
48 *self == DriverType::Poll
49 }
50
51 pub fn is_iouring(&self) -> bool {
53 *self == DriverType::IoUring
54 }
55
56 pub fn is_iocp(&self) -> bool {
58 *self == DriverType::IOCP
59 }
60}