Skip to main content

OpCode

Trait OpCode 

pub unsafe trait OpCode {
    type Control: Default;

    // Required methods
    fn pre_submit(&mut self, _: &mut Self::Control) -> Result<Decision, Error>;
    fn operate(&mut self, _: &mut Self::Control) -> Poll<Result<usize, Error>>;

    // Provided methods
    unsafe fn init(&mut self, _: &mut Self::Control) { ... }
    fn op_type(&mut self, _: &mut Self::Control) -> Option<OpType> { ... }
    unsafe fn set_result(
        &mut self,
        _: &mut Self::Control,
        _: &Result<usize, Error>,
        _: &Extra,
    ) { ... }
}
Expand description

Abstraction of operations.

§Safety

If pre_submit returns Decision::Wait, op_type must also return Some(OpType::Fd) with same fds as the WaitArgs. Similarly, if pre_submit returns Decision::Aio, op_type must return Some(OpType::Aio) with the correct aiocb pointer.

Required Associated Types§

type Control: Default

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

Required Methods§

fn pre_submit(&mut self, _: &mut Self::Control) -> Result<Decision, Error>

Perform the operation before submit, and return Decision to indicate whether submitting the operation to polling is required.

fn operate(&mut self, _: &mut Self::Control) -> Poll<Result<usize, Error>>

Perform the operation after received corresponding event. If this operation is blocking, the return value should be Poll::Ready.

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(&mut self, _: &mut Self::Control) -> Option<OpType>

Get the operation type when an event is occurred.

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§

§

impl OpCode for CloseFile

§

type Control = ()

§

impl OpCode for CloseSocket

§

type Control = ()

§

impl OpCode for CreateSocket

§

type Control = ()

§

impl OpCode for Pipe

§

type Control = ()

§

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

§

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> OpCode for HardLink<S1, S2>
where S1: AsFd, S2: AsFd,

§

type Control = ()

§

impl<S1, S2> OpCode for Rename<S1, S2>
where S1: AsFd, S2: AsFd,

§

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> OpCode for Accept<S>
where S: AsFd,

§

type Control = ()

§

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

§

type Control = <Accept<S> as OpCode>::Control

§

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

§

type Control = ()

§

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

§

type Control = ()

§

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

§

type Control = ()

§

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

§

type Control = ()

§

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

§

type Control = ()

§

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

§

type Control = ()

§

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

§

type Control = ()

§

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

§

type Control = ()

§

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

§

type Control = ()

§

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

§

type Control = AioControl

§

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

§

type Control = ()

§

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

§

type Control = ()

§

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

§

type Control = ()

§

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

§

type Control = RecvMsgControl

§

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

§

type Control = ()

§

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

§

type Control = ()

§

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

§

type Control = AioControl

§

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

§

type Control = ()

§

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

§

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<T, C, S> OpCode for RecvMsg<T, C, S>
where T: IoVectoredBufMut, C: IoBufMut, S: AsFd,

§

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 = AioControl

§

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

§

type Control = VectoredControl

§

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

§

type Control = AioControl<VectoredControl>

§

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

§

type Control = ()

§

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

§

type Control = ()

§

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

§

type Control = RecvMsgControl

§

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 = ()

§

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

§

type Control = ()

§

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

§

type Control = SendMsgControl

§

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 = AioControl

§

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

§

type Control = VectoredControl

§

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

§

type Control = AioControl<VectoredControl>