Skip to main content

compio_driver/sys/op/managed/
poll.rs

1use super::fallback::*;
2use crate::{Decision, OpType, PollOpCode as OpCode, op::RecvMsgControl, sys::prelude::*};
3
4unsafe impl<S: AsFd> OpCode for ReadManaged<S> {
5    type Control = ();
6
7    fn pre_submit(&mut self, control: &mut Self::Control) -> io::Result<Decision> {
8        self.op.pre_submit(control)
9    }
10
11    fn op_type(&mut self, control: &mut Self::Control) -> Option<crate::OpType> {
12        self.op.op_type(control)
13    }
14
15    fn operate(&mut self, control: &mut Self::Control) -> Poll<io::Result<usize>> {
16        self.op.operate(control)
17    }
18}
19
20unsafe impl<S: AsFd> OpCode for ReadManagedAt<S> {
21    type Control = AioControl;
22
23    unsafe fn init(&mut self, ctrl: &mut Self::Control) {
24        unsafe { self.op.init(ctrl) }
25    }
26
27    fn pre_submit(&mut self, control: &mut Self::Control) -> io::Result<Decision> {
28        self.op.pre_submit(control)
29    }
30
31    fn op_type(&mut self, control: &mut Self::Control) -> Option<OpType> {
32        self.op.op_type(control)
33    }
34
35    fn operate(&mut self, control: &mut Self::Control) -> Poll<io::Result<usize>> {
36        self.op.operate(control)
37    }
38}
39
40unsafe impl<S: AsFd> OpCode for RecvManaged<S> {
41    type Control = ();
42
43    fn pre_submit(&mut self, control: &mut Self::Control) -> io::Result<Decision> {
44        self.op.pre_submit(control)
45    }
46
47    fn op_type(&mut self, control: &mut Self::Control) -> Option<crate::OpType> {
48        self.op.op_type(control)
49    }
50
51    fn operate(&mut self, control: &mut Self::Control) -> Poll<io::Result<usize>> {
52        self.op.operate(control)
53    }
54}
55
56unsafe impl<S: AsFd> OpCode for RecvFromManaged<S> {
57    type Control = ();
58
59    fn pre_submit(&mut self, control: &mut Self::Control) -> io::Result<Decision> {
60        self.op.pre_submit(control)
61    }
62
63    fn op_type(&mut self, control: &mut Self::Control) -> Option<OpType> {
64        self.op.op_type(control)
65    }
66
67    fn operate(&mut self, control: &mut Self::Control) -> Poll<io::Result<usize>> {
68        self.op.operate(control)
69    }
70}
71
72unsafe impl<S: AsFd> OpCode for RecvFromMulti<S> {
73    type Control = ();
74
75    fn pre_submit(&mut self, control: &mut Self::Control) -> io::Result<Decision> {
76        self.op.pre_submit(control)
77    }
78
79    fn op_type(&mut self, control: &mut Self::Control) -> Option<OpType> {
80        self.op.op_type(control)
81    }
82
83    fn operate(&mut self, control: &mut Self::Control) -> Poll<io::Result<usize>> {
84        self.op.operate(control)
85    }
86
87    unsafe fn set_result(
88        &mut self,
89        _: &mut Self::Control,
90        result: &io::Result<usize>,
91        _: &crate::Extra,
92    ) {
93        if let Ok(result) = result {
94            self.len = *result;
95        }
96    }
97}
98
99unsafe impl<C: IoBufMut, S: AsFd> OpCode for RecvMsgManaged<C, S> {
100    type Control = RecvMsgControl;
101
102    unsafe fn init(&mut self, ctrl: &mut Self::Control) {
103        unsafe { self.op.init(ctrl) }
104    }
105
106    fn pre_submit(&mut self, control: &mut Self::Control) -> io::Result<Decision> {
107        self.op.pre_submit(control)
108    }
109
110    fn op_type(&mut self, control: &mut Self::Control) -> Option<OpType> {
111        self.op.op_type(control)
112    }
113
114    fn operate(&mut self, control: &mut Self::Control) -> Poll<io::Result<usize>> {
115        self.op.operate(control)
116    }
117
118    unsafe fn set_result(
119        &mut self,
120        control: &mut Self::Control,
121        result: &io::Result<usize>,
122        extra: &crate::Extra,
123    ) {
124        unsafe { self.op.set_result(control, result, extra) }
125    }
126}
127
128unsafe impl<S: AsFd> OpCode for RecvMsgMulti<S> {
129    type Control = RecvMsgControl;
130
131    unsafe fn init(&mut self, ctrl: &mut Self::Control) {
132        unsafe { self.op.init(ctrl) }
133    }
134
135    fn pre_submit(&mut self, control: &mut Self::Control) -> io::Result<Decision> {
136        self.op.pre_submit(control)
137    }
138
139    fn op_type(&mut self, control: &mut Self::Control) -> Option<OpType> {
140        self.op.op_type(control)
141    }
142
143    fn operate(&mut self, control: &mut Self::Control) -> Poll<io::Result<usize>> {
144        self.op.operate(control)
145    }
146
147    unsafe fn set_result(
148        &mut self,
149        control: &mut Self::Control,
150        result: &io::Result<usize>,
151        extra: &crate::Extra,
152    ) {
153        unsafe { self.op.set_result(control, result, extra) };
154        if let Ok(result) = result {
155            self.len = *result;
156        }
157    }
158}