o3 0.62.0

shared-nothing primitives
Documentation
use std::num::NonZero;

use crate::{base::num::bounded::Overflow, buffer, buffer::bytes::bounded};

/// A stable owner whose byte extent exceeds the signed count domain.
#[repr(transparent)]
pub struct Rejected<T: buffer::raw::Source> {
    source: T,
}

impl<T: buffer::raw::Source> Rejected<T> {
    pub(in crate::buffer::bytes::bounded) const fn new(source: T) -> Self {
        Self { source }
    }

    pub fn into_parts(self) -> (T, Overflow<{ bounded::MAX as u32 }>) {
        let excess = NonZero::<usize>::MIN
            .saturating_add(self.source.as_ref().len().saturating_sub(bounded::MAX + 1));
        (self.source, Overflow::new(excess))
    }
}