dope-core 0.77.0

Owned native I/O and completion driver for dope
Documentation
use std::{mem, os::fd};

use dope_sys::{engine, io::reactor::complete::Observe};

use crate::{
    Backend, Engine,
    driver::route::{indices, table::bounds},
};

mod cause;
mod error;
pub mod fault;

pub use cause::Cause;
pub use error::Error;

trait Native {
    type Observation;
    type Error;
}

impl Native for Backend {
    type Observation = <Engine as Observe>::Observation;
    type Error = <Engine as engine::raw::Poll>::Error;
}

/// Exact reactor operation that failed on a readiness-queue backend.
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
pub enum Operation {
    Wait,
    Changes,
    Accept,
    Connect,
    SocketError,
    Recv,
    RecvMsg,
    Send,
    Shutdown,
    FileOpen,
    FileWrite,
    FileSync,
    FileRename,
    FileUnlink,
}

/// Exact descriptor-table absence observed by a readiness backend.
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
#[repr(u8)]
pub enum Missing {
    Bounds(bounds::Excluded),
    Backing {
        index: indices::SlotIndex,
    },
    Vacant {
        index: indices::SlotIndex,
    },
    Replaced {
        index: indices::SlotIndex,
        expected: fd::RawFd,
        actual: fd::RawFd,
    },
}

/// Backend publication progress, not completion of submitted I/O.
#[derive(Clone, Copy, Eq, PartialEq)]
#[must_use = "pending backend changes must be committed in a later reactor turn"]
pub enum Commit {
    /// Every change queued before this call has reached the backend.
    Drained,
    /// Queued changes remain and require another reactor turn.
    Pending,
}

const _: () = {
    assert!(mem::size_of::<Missing>() == 4 * mem::size_of::<u32>());
    assert!(mem::align_of::<Missing>() == mem::align_of::<u32>());
    assert!(mem::size_of::<Operation>() == 1);
    assert!(core::mem::size_of::<Result<(), Error>>() == core::mem::size_of::<Error>());
    assert!(core::mem::size_of::<Result<Commit, Error>>() == core::mem::size_of::<Error>());
};