pub use bound::Bound;
pub use chunks::Chunks;
use dope_core::io::transfer;
use o3::buffer::storage::inline;
use crate::link::egress::ResidentSize;
mod chunks;
pub mod compose;
pub mod exec;
pub mod pair;
pub mod raw;
#[derive(Clone, Copy, Eq, PartialEq, PartialOrd, Ord)]
#[repr(transparent)]
pub struct Offset(usize);
pub enum Split {
Before(Offset),
After(Offset),
}
impl Offset {
pub const ZERO: Self = Self(0);
pub const fn from_len(bytes: transfer::Len) -> Self {
Self(bytes.into_raw())
}
pub const fn get(self) -> usize {
self.0
}
pub(in crate::link) const fn is_at_least(self, bytes: usize) -> bool {
self.0 >= bytes
}
pub const fn split_at(self, at: usize) -> Split {
if self.0 < at {
Split::Before(self)
} else {
Split::After(Self(self.0 - at))
}
}
pub fn tail(self, bytes: &[u8]) -> Option<&[u8]> {
bytes.get(self.0..).filter(|tail| !tail.is_empty())
}
}
const _: () = assert!(std::mem::size_of::<Offset>() == std::mem::size_of::<usize>());
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum Execution {
Fallible,
Bounded(ResidentSize),
Unbounded,
}
mod bound;
pub type Inline<const N: usize> = inline::Bytes<N, u16>;
const _: () = assert!(std::mem::size_of::<Inline<514>>() == 516);
unsafe impl<'d, const N: usize> raw::Contiguous<'d> for Inline<N> {}