Skip to main content

OpCode

Trait OpCode 

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

Source

type Control: Default

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

Required Methods§

Source

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.

Source

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§

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

Get the operation type when an event is occurred.

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.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl OpCode for CloseFile

Source§

impl OpCode for CloseSocket

Source§

impl OpCode for CreateSocket

Source§

impl OpCode for Pipe

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<S> OpCode for PollOnce<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§

type Control = AioControl

Source§

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

Source§

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

Source§

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

Source§

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

Source§

type Control = RecvMsgControl

Source§

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

Source§

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

Source§

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

Source§

type Control = AioControl

Source§

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

Source§

impl<S> OpCode for Unlink<S>
where S: 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§

type Control = AioControl

Source§

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

Source§

type Control = VectoredControl

Source§

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

Source§

type Control = AioControl<VectoredControl>

Source§

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

Source§

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

Source§

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

Source§

type Control = RecvMsgControl

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§

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

Source§

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

Source§

type Control = SendMsgControl

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,

Source§

type Control = AioControl

Source§

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

Source§

type Control = VectoredControl

Source§

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

Source§

type Control = AioControl<VectoredControl>