dope-core 0.76.0

Owned native I/O and completion driver for dope
Documentation
use dope_sys::{
    io::reactor::{complete::flags::Flow, event::kind},
    table::token::host,
};

use crate::{
    driver::{
        self, receive,
        result::poll::fault::Observation,
        retained::flight::{self, GENERATION_BITS, INDEX_BITS, Target, storage},
        route::{self, kind::Any},
    },
    io::{
        event::net::{Owned, accept, socket},
        fd::handles,
        transfer::Len,
    },
};

#[must_use = "a validated flight completion must be committed"]
pub struct Complete<'d> {
    pub(super) completion: storage::Complete<'d, Target, INDEX_BITS, GENERATION_BITS>,
    pub(super) driver: driver::Reference<'d>,
}

impl<'d> host::Flight for Complete<'d> {
    type Key = flight::Echo;
    type Token = route::Token;
    type Target<K: kind::Flight> = route::Erased<'d, K>;
    type Length = Len;
    type Descriptor = handles::Descriptor<'d>;
    type AcceptFailure = accept::Failure;
    type Created = handles::CreatedSlot<'d>;
    type SocketFailure = socket::Failure;
    type Exhausted = receive::Exhausted<'d>;
    type Owned = Owned<'d>;
    type Observation = Observation;
    type Fault = <flight::Arena as host::raw::Drain>::Fault;
    type Reported = <flight::Arena as host::raw::Drain>::Reported;

    fn finish(self) {
        self.completion.finish();
    }

    fn end(self, flow: Flow) -> Self::Key {
        let echo = flight::Echo::from_inner(self.completion.echo());
        if flow == Flow::Last {
            self.completion.finish();
        }
        echo
    }

    fn kind(&self) -> kind::Native {
        self.completion.value().kind
    }

    fn target<K: kind::Flight>(&self, proof: kind::Witness<K>) -> Self::Target<K> {
        self.completion.value().bind_native(
            self.driver.brand,
            flight::Echo::from_inner(self.completion.echo()),
            proof,
        )
    }

    fn settle<K: kind::Flight>(self, proof: kind::Witness<K>, flow: Flow) -> Self::Target<K> {
        let echo = flight::Echo::from_inner(self.completion.echo());
        self.completion
            .settle(flow)
            .bind_native(self.driver.brand, echo, proof)
    }

    fn reject(self, flow: Flow) -> Self::Token {
        let echo = flight::Echo::from_inner(self.completion.echo());
        self.completion
            .settle(flow)
            .bind::<Any>(self.driver.brand, echo)
            .into_token()
    }

    fn owned(
        self,
        _: kind::Witness<kind::SendOwned>,
        result: Result<Len, crate::Errno>,
    ) -> Self::Owned {
        Owned::new(self.completion, self.driver.brand, result)
    }
}