Skip to main content

compio_driver/sys/op/multishot/
poll.rs

1use crate::{Decision, OpType, PollOpCode as OpCode, sys::op::*};
2
3/// Accept multiple connections.
4pub struct AcceptMulti<S> {
5    pub(crate) op: Accept<S>,
6}
7
8impl<S> AcceptMulti<S> {
9    /// Create [`AcceptMulti`].
10    pub fn new(fd: S) -> Self {
11        Self {
12            op: Accept::new(fd),
13        }
14    }
15}
16
17impl<S> IntoInner for AcceptMulti<S> {
18    type Inner = Socket2;
19
20    fn into_inner(self) -> Self::Inner {
21        self.op.into_inner().0
22    }
23}
24
25unsafe impl<S: AsFd> OpCode for AcceptMulti<S> {
26    type Control = <Accept<S> as OpCode>::Control;
27
28    unsafe fn init(&mut self, ctrl: &mut Self::Control) {
29        unsafe { self.op.init(ctrl) }
30    }
31
32    fn pre_submit(&mut self, control: &mut Self::Control) -> io::Result<Decision> {
33        self.op.pre_submit(control)
34    }
35
36    fn op_type(&mut self, control: &mut Self::Control) -> Option<OpType> {
37        self.op.op_type(control)
38    }
39
40    fn operate(&mut self, control: &mut Self::Control) -> Poll<io::Result<usize>> {
41        self.op.operate(control)
42    }
43}