Skip to main content

OpCode

Trait OpCode 

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

Abstraction of IOCP operations.

§Safety

Implementors must ensure that the operation is safe to be polled according to the returned OpType.

Required Associated Types§

type Control: Default

Type that contains self-references and other needed info during the operation

Required Methods§

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

Provided Methods§

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.

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.

fn cancel( &mut self, control: &mut Self::Control, optr: *mut OVERLAPPED, ) -> Result<(), Error>

Cancel the async IO operation.

Usually it calls CancelIoEx.

unsafe fn set_result( &mut self, _: &mut Self::Control, _: &Result<usize, Error>, _: &Extra, )

Set the result when it completes. The operation stores the result and is responsible to release it if the operation is cancelled.

§Safety

The params must be the result coming from this operation.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

§

impl OpCode for CloseFile

§

type Control = ()

§

impl OpCode for CloseSocket

§

type Control = ()

§

impl<C, S> OpCode for RecvMsgManaged<C, S>
where C: IoBufMut, S: AsSocketState,

§

type Control = RecvMsgControl

§

impl<D, F> OpCode for Asyncify<F, D>
where D: Send + 'static, F: FnOnce() -> BufResult<usize, D> + Send + 'static,

§

type Control = ()

§

impl<S1, S2, D, F> OpCode for AsyncifyFd2<S1, S2, F, D>
where S1: Sync, S2: Sync, D: Send + 'static, F: FnOnce(&S1, &S2) -> BufResult<usize, D> + Send + 'static,

§

type Control = ()

§

impl<S, D, F> OpCode for AsyncifyFd<S, F, D>
where S: Sync, D: Send + 'static, F: FnOnce(&S) -> BufResult<usize, D> + Send + 'static,

§

type Control = ()

§

impl<S, SA> OpCode for Accept<S, SA>
where S: AsSocketState, SA: AsFd,

§

type Control = ()

§

impl<S> OpCode for Connect<S>
where S: AsSocketState,

§

type Control = ()

§

impl<S> OpCode for ConnectNamedPipe<S>
where S: AsFd,

§

type Control = ()

§

impl<S> OpCode for Disconnect<S>
where S: AsSocketState,

§

type Control = ()

§

impl<S> OpCode for ReadManaged<S>
where S: AsFd,

§

type Control = ()

§

impl<S> OpCode for ReadManagedAt<S>
where S: AsFd,

§

type Control = ()

§

impl<S> OpCode for RecvFromManaged<S>
where S: AsFd,

§

type Control = RecvFromControl

§

impl<S> OpCode for RecvFromMulti<S>
where S: AsFd,

§

type Control = RecvFromControl

§

impl<S> OpCode for RecvManaged<S>
where S: AsFd,

§

type Control = RecvControl

§

impl<S> OpCode for RecvMsgMulti<S>
where S: AsSocketState,

§

type Control = RecvMsgControl

§

impl<S> OpCode for Sync<S>
where S: AsFd,

§

type Control = ()

§

impl<T, C, S> OpCode for RecvMsg<T, C, S>

§

type Control = RecvMsgControl

§

impl<T, C, S> OpCode for SendMsg<T, C, S>
where T: IoVectoredBuf, C: IoBuf, S: AsFd,

§

type Control = SendMsgControl

§

impl<T, S> OpCode for Read<T, S>
where T: IoBufMut, S: AsFd,

§

type Control = ()

§

impl<T, S> OpCode for ReadAt<T, S>
where T: IoBufMut, S: AsFd,

§

type Control = ()

§

impl<T, S> OpCode for Recv<T, S>
where T: IoBufMut, S: AsFd,

§

type Control = RecvControl

§

impl<T, S> OpCode for RecvFrom<T, S>
where T: IoBufMut, S: AsFd,

§

type Control = RecvFromControl

§

impl<T, S> OpCode for RecvFromVectored<T, S>
where T: IoVectoredBufMut, S: AsFd,

§

type Control = RecvFromVectoredControl

§

impl<T, S> OpCode for RecvVectored<T, S>
where T: IoVectoredBufMut, S: AsFd,

§

type Control = RecvVectoredControl

§

impl<T, S> OpCode for Send<T, S>
where T: IoBuf, S: AsFd,

§

type Control = SendControl

§

impl<T, S> OpCode for SendTo<T, S>
where T: IoBuf, S: AsFd,

§

type Control = SendToControl

§

impl<T, S> OpCode for SendToVectored<T, S>
where T: IoVectoredBuf, S: AsFd,

§

type Control = SendToVectoredControl

§

impl<T, S> OpCode for SendVectored<T, S>
where T: IoVectoredBuf, S: AsFd,

§

type Control = SendVectoredControl

§

impl<T, S> OpCode for Write<T, S>
where T: IoBuf, S: AsFd,

§

type Control = ()

§

impl<T, S> OpCode for WriteAt<T, S>
where T: IoBuf, S: AsFd,

§

type Control = ()