dope-uring 0.76.0

Owned io_uring backend for dope
Documentation
use std::mem;

use dope_sys::{io::reactor::complete, ring::Source, table::token};
use dope_uring::Backend;

use crate::common::cleanup;

type Entry = <Backend as Source>::Entry<()>;
type Outcome = <Entry as complete::Entry>::Outcome;
type Returned = <Outcome as complete::Outcome>::Returned;
type Token = <Backend as token::Source>::Token<cleanup::Host>;

pub trait Word {
    type Native;

    fn native(self) -> Self::Native;
}

impl Word for i32 {
    type Native = Outcome;

    fn native(self) -> Outcome {
        // SAFETY: the native result is transparent over i32 and admits every kernel word.
        unsafe { mem::transmute(self) }
    }
}

impl Word for u64 {
    type Native = Token;

    fn native(self) -> Token {
        // SAFETY: the native token is transparent over u64 and admits every kernel word.
        unsafe { mem::transmute(self) }
    }
}

pub trait Rejected {
    fn word(self) -> i32;
}

impl Rejected for Returned {
    fn word(self) -> i32 {
        // SAFETY: Returned preserves the transparent native result without changing its bits.
        unsafe { mem::transmute(self) }
    }
}