dope-sys 0.78.0

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

/// Selects native pending and completed provided-buffer ownership.
pub trait Source {
    const PROVIDED: u16;
    const CANARY: u16;
    type Index: buffer::Index;
    type Context<L: memory::raw::Receive>: Context<Layout = L, Complete = Self::Complete<L::Extent>>;
    type Canary<L: memory::raw::Canary>: canary::raw::Storage<
            Layout = L,
            Index = Self::Index,
            State = <Self::Context<L> as Context>::Cleanup,
            Error = <Self::Context<L> as Context>::Error,
        >;
    type Producer<L: memory::raw::Receive>: Producer<
            Layout = L,
            Context = Self::Context<L>,
            Pending = Self::Pending<L::Extent>,
            Index = Self::Index,
        >;
    type Pending<E: memory::raw::Extent>: buffer::raw::Token<Index = Self::Index, Length = E::Capacity>
        + buffer::raw::Pending<Extent = E, Complete = Self::Complete<E>>;
    type Complete<E: memory::raw::Extent>: buffer::raw::Token<Index = Self::Index, Length = E::Length>;
}

/// Payload ownership and exact completed-prefix projection for one receive ring.
pub trait Context: Close + memory::Context + buffer::raw::Context<Self::Complete> {
    type Error: Failure<Cleanup = Self::Cleanup>;
    type Cleanup: Retry + memory::Failure;
    type Complete: buffer::raw::Token;

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

/// Native ring entries and deferred publication, paired with one payload owner.
pub trait Producer: Close + buffer::raw::Select + Sized {
    type Layout: memory::raw::Receive;
    type Context: Context;
    type Error: Open<Context = Self::Context, Cleanup = <Self::Context as Context>::Cleanup>;

    fn new(context: &Self::Context) -> Result<Self, Self::Error>;
    fn flush(&mut self);
    fn layout(&self) -> Self::Layout;
}

/// The original mapping failure and any storage still requiring cleanup.
pub trait Failure {
    type Cleanup: Retry + memory::Failure;

    fn into_parts(self) -> (memory::Error, Option<Self::Cleanup>);
}

/// A failed producer allocation that can retire its paired payload owner.
pub trait Open: Failure {
    type Context: Context;

    fn close(self, context: Self::Context) -> <Self::Context as Context>::Error;
}