io-uring-opcode 0.2.0-pre2

io_uring opcode trait contract between bearer and opcodes
Documentation
//! UringOpCode represents the API between the io-uring-bearer and the
//! individual io_uring OpCode handlers which are sepated into different
//! crates.

#[cfg(feature = "epoll")]
mod epoll_ctl;
#[cfg(feature = "epoll")]
pub use epoll_ctl::OpExtEpollCtl;

use core::pin::Pin;
use io_uring_owner::Owner;

use crate::OpError;

/// Pending Completion type implemented by the OpCode handlers.
pub trait OpCompletion {
    /// It is recommended that you use a harmonized error type but is not mandatory.
    type Error;
    /// Provide the squeue entry
    fn entry(&self) -> io_uring::squeue::Entry;
    /// Get the current Owner
    fn owner(&self) -> Owner;
    /// Force set the owner to Kernel
    fn force_owner_kernel(&mut self) -> bool;
}

/// The contracting type between io-uring-bearer and all the opcodes it can carry.
/// Implement this type in the individual opcodes that can be used in the bearer.
pub trait OpCode<C: OpCompletion> {
    /// It is recommended that you use a harmonized error type but is not mandatory.
    // Turn the abstract OpCoe into Submission that will be pending completion.
    // io-uring-bearer will call this in order to convert the higher level type into actual submission.
    fn submission(self) -> Result<C, OpError>;
    /// io-uring-bearer will call this upno completion
    fn completion(&mut self, _: Pin<&mut C>) -> Result<(), OpError>;
}