Skip to main content

OpCode

Trait OpCode 

Source
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§

Source

type Control: Default

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

Required Methods§

Source

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§

Source

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.

Source

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.

Source

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

Cancel the async IO operation.

Usually it calls CancelIoEx.

Source

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.

Implementors§

Source§

impl OpCode for CloseFile

Source§

impl OpCode for CloseSocket

Source§

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

Source§

type Control = RecvMsgControl

Source§

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

Source§

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,

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

type Control = RecvFromControl

Source§

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

Source§

type Control = RecvFromControl

Source§

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

Source§

type Control = RecvControl

Source§

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

Source§

type Control = RecvMsgControl

Source§

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

Source§

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

Source§

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

Source§

impl<T, C, S> OpCode for RecvMsg<T, C, S>
where T: IoVectoredBufMut, C: IoBufMut, S: AsFd,

Source§

type Control = RecvMsgControl

Source§

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

Source§

type Control = SendMsgControl

Source§

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

Source§

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

Source§

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

Source§

type Control = RecvControl

Source§

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

Source§

type Control = RecvFromControl

Source§

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

Source§

type Control = RecvFromVectoredControl

Source§

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

Source§

type Control = RecvVectoredControl

Source§

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

Source§

type Control = SendControl

Source§

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

Source§

type Control = SendToControl

Source§

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

Source§

type Control = SendToVectoredControl

Source§

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

Source§

type Control = SendVectoredControl

Source§

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

Source§

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