dope-core 0.75.0

Owned native I/O and completion driver for dope
Documentation
use crate::{
    Errno,
    driver::{retained::flight, route, route::kind},
    io::event::entry::Entry,
};

/// A terminal socket-option transaction completion.
#[repr(transparent)]
pub struct Completion<'d>(Entry<'d, kind::Tuning, Result<u32, Errno>>);

impl<'d> Completion<'d> {
    pub const fn token(&self) -> route::Erased<'d, kind::Tuning> {
        self.0.token()
    }

    pub const fn outcome(&self) -> Result<u32, Errno> {
        *self.0.value()
    }

    pub(crate) fn from_value(
        bound: flight::Complete<'d, kind::Tuning>,
        value: Result<u32, Errno>,
    ) -> Self {
        Self(Entry::new(bound.complete(), value))
    }
}

impl<'d> From<(flight::Complete<'d, kind::Tuning>, Result<(), Errno>)> for Completion<'d> {
    fn from((target, outcome): (flight::Complete<'d, kind::Tuning>, Result<(), Errno>)) -> Self {
        Self::from_value(target, outcome.map(|()| 0))
    }
}