pub unsafe trait OpCode {
type Control: Default;
// Required method
unsafe fn operate(
&mut self,
control: &mut Self::Control,
optr: *mut OVERLAPPED,
) -> Poll<Result<usize, Error>>;
// Provided methods
unsafe fn init(&mut self, _: &mut Self::Control) { ... }
fn op_type(&self, control: &Self::Control) -> OpType { ... }
fn cancel(
&mut self,
control: &mut Self::Control,
optr: *mut OVERLAPPED,
) -> Result<(), Error> { ... }
unsafe fn set_result(
&mut self,
_: &mut Self::Control,
_: &Result<usize, Error>,
_: &Extra,
) { ... }
}Expand description
Required Associated Types§
Required Methods§
Sourceunsafe fn operate(
&mut self,
control: &mut Self::Control,
optr: *mut OVERLAPPED,
) -> Poll<Result<usize, Error>>
unsafe fn operate( &mut self, control: &mut Self::Control, optr: *mut OVERLAPPED, ) -> Poll<Result<usize, Error>>
Perform Windows API call with given pointer to overlapped struct.
It is always safe to cast optr to a pointer to
Overlapped<Self>.
Don’t do heavy work here if OpCode::op_type returns
OpType::Event.
§Safety
selfmust be alive until the operation completes.- When
OpCode::op_typereturnsOpType::Blocking, this method is called in another thread.
Provided Methods§
Sourceunsafe fn init(&mut self, _: &mut Self::Control)
unsafe fn init(&mut self, _: &mut Self::Control)
Initialize the control
§Safety
Caller must guarantee that during the lifetime of ctrl, Self is
unmoved and valid.
Sourcefn op_type(&self, control: &Self::Control) -> OpType
fn op_type(&self, control: &Self::Control) -> OpType
Determines that the operation is really overlapped defined by Windows API. If not, the driver will try to operate it in another thread.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".