use super::*;
pub unsafe trait OpCode {
type Control: Default;
unsafe fn init(&mut self, _: &mut Self::Control) {}
fn op_type(&self, control: &Self::Control) -> OpType {
_ = control;
OpType::Overlapped
}
unsafe fn operate(
&mut self,
control: &mut Self::Control,
optr: *mut OVERLAPPED,
) -> Poll<io::Result<usize>>;
fn cancel(&mut self, control: &mut Self::Control, optr: *mut OVERLAPPED) -> io::Result<()> {
_ = control;
_ = optr;
Ok(())
}
unsafe fn set_result(
&mut self,
_: &mut Self::Control,
_: &io::Result<usize>,
_: &crate::Extra,
) {
}
}
pub(crate) trait Carry {
fn op_type(&self) -> OpType;
unsafe fn operate(&mut self, optr: *mut OVERLAPPED) -> Poll<io::Result<usize>>;
fn cancel(&mut self, optr: *mut OVERLAPPED) -> io::Result<()>;
unsafe fn set_result(&mut self, _: &io::Result<usize>, _: &crate::Extra);
}
impl<T: OpCode> Carry for Carrier<T> {
fn op_type(&self) -> OpType {
let (op, control) = self.as_iocp();
op.op_type(control)
}
unsafe fn operate(&mut self, optr: *mut OVERLAPPED) -> Poll<io::Result<usize>> {
let (op, control) = self.as_iocp_mut();
unsafe { op.operate(control, optr) }
}
fn cancel(&mut self, optr: *mut OVERLAPPED) -> io::Result<()> {
let (op, control) = self.as_iocp_mut();
op.cancel(control, optr)
}
unsafe fn set_result(&mut self, res: &io::Result<usize>, extra: &crate::Extra) {
let (op, control) = self.as_iocp_mut();
unsafe { op.set_result(control, res, extra) }
}
}