o3 0.62.0

shared-nothing primitives
Documentation
use std::{cell, marker, ptr};

use crate::buffer::{self, pool, storage};

pub(in crate::buffer::pool) use header::Header;
use header::Shape;
pub(in crate::buffer) use measured::Measured;
use sealed::Free;
pub(in crate::buffer::pool) use sealed::Key;
pub(in crate::buffer) use sealed::account::{Account, Accounts};

mod header;
mod measured;

pub mod raw;
mod sealed;

/// One counted pool-slot edge retaining its original root mode.
#[derive(Debug)]
#[repr(transparent)]
pub struct Edge<K: crate::buffer::raw::Backing = Plain, M = pool::Owned> {
    slot: crate::mem::raw::Owner<raw::Slot<K>>,
    mode: marker::PhantomData<M>,
}

impl<K: crate::buffer::raw::Backing, M> Edge<K, M> {
    pub(in crate::buffer) fn into_raw(self) -> ptr::NonNull<storage::raw::Prefix> {
        self.slot.into_raw().cast()
    }
}

impl<K: crate::buffer::raw::Backing, M> buffer::Residency for Option<Edge<K, M>> {
    fn resident(&self) -> usize {
        self.as_ref().map_or(0, raw::Slot::resident)
    }
}

impl<K: crate::buffer::raw::Backing, M, S> From<pool::Span<K, M, S>> for Edge<K, M> {
    fn from(span: pool::Span<K, M, S>) -> Self {
        raw::Slot::share(span)
    }
}

#[derive(Debug)]
pub struct Plain<L = super::Layout>(marker::PhantomData<fn() -> L>);

impl<L> Default for Plain<L> {
    fn default() -> Self {
        Self(marker::PhantomData)
    }
}

#[derive(Debug)]
#[repr(transparent)]
pub struct Resident<'d> {
    account: cell::Cell<u32>,
    brand: marker::PhantomData<fn(&'d ()) -> &'d ()>,
}

impl Default for Resident<'_> {
    fn default() -> Self {
        Self {
            account: cell::Cell::new(sealed::END),
            brand: marker::PhantomData,
        }
    }
}