dope-sys 0.77.0

Typed operating-system call contracts
Documentation
use crate::{
    io::Retry,
    memory,
    memory::buffer::{canary::Failure, provided},
};

type Extent<S> = <<S as Storage>::Layout as memory::raw::Receive>::Extent;
type Inspection<S, E> = Failure<
    <S as Storage>::Index,
    <Extent<S> as memory::raw::Extent>::Length,
    <Extent<S> as memory::raw::Extent>::Capacity,
    E,
>;

/// One owner retains canary payloads and registration entries.
pub trait Storage: Sized {
    type Layout: memory::raw::Canary;
    type Index: Copy;
    type State: Retry<Owner: From<Self>> + memory::Failure;
    type Error: provided::Failure<Cleanup = Self::State>;

    fn new() -> Result<Self, Self::Error>;

    /// # Safety
    /// A unique CQE transfers any valid reported slot; no other access remains.
    unsafe fn inspect<E>(
        &mut self,
        index: Self::Index,
        len: <<Self::Layout as memory::raw::Receive>::Extent as memory::raw::Extent>::Length,
        check: impl FnOnce(&[u8]) -> Result<(), E>,
    ) -> Result<(), Inspection<Self, E>>;
}