dope-core 0.76.0

Owned native I/O and completion driver for dope
Documentation
use crate::driver::{
    retained::flight::{GENERATION_BITS, INDEX_BITS, Reserved, Target, storage},
    route::kind::Class,
};

#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[repr(transparent)]
pub struct Echo(storage::Echo<Target, INDEX_BITS, GENERATION_BITS>);

impl From<Echo> for u64 {
    fn from(echo: Echo) -> Self {
        echo.0.expose()
    }
}

impl From<Echo> for usize {
    fn from(echo: Echo) -> Self {
        const { assert!(usize::BITS >= u64::BITS) };
        u64::from(echo) as usize
    }
}

impl Echo {
    pub(crate) const BITS: u32 = INDEX_BITS + GENERATION_BITS;

    pub(crate) const fn from_inner(
        echo: storage::Echo<Target, INDEX_BITS, GENERATION_BITS>,
    ) -> Self {
        Self(echo)
    }

    pub(in crate::driver::retained::flight) const fn into_inner(
        self,
    ) -> storage::Echo<Target, INDEX_BITS, GENERATION_BITS> {
        self.0
    }
}

impl<C: Class> From<&Reserved<'_, C>> for Echo {
    fn from(reserved: &Reserved<'_, C>) -> Self {
        Self::from_inner(reserved.reservation.echo())
    }
}