use crate::{
Errno,
driver::{retained::flight, route, route::kind},
io::event::entry::Entry,
};
#[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))
}
}