pipecircuit 0.0.25

Correct. Robust. Fast. Portable. Pick four.
Documentation
mod backing;
#[cfg(feature = "alloc")]
pub use backing::AllocatedStableSlots;
pub use backing::{
    CallerStableSlots, StableSlotColumn, StableSlotsBacking, StableSlotsStorageError,
    StableSlotsStorageRefusal,
};

#[cfg(feature = "alloc")]
mod creation;
mod inconsistency;
mod insert;
mod lookup;
mod remove;

#[cfg(feature = "alloc")]
pub use creation::StableSlotsCreationError;
pub use inconsistency::StableSlotsInconsistency;
pub use insert::{PreparedStableSlotInsert, StableSlotInsertError};
#[cfg(feature = "secondary-indexes")]
pub use lookup::StableSlotResolutions;
pub use lookup::{StableSlotResolveOutcome, StableSlotResolver};
pub use remove::{PreparedStableSlotRemove, StableSlotRemoveOutcome, StableSlotRowRelocation};

pub use crate::storage::StableSlot;

pub enum SlotLocation {
    Occupied(u32),
    Free(Option<StableSlot>),
}

pub struct StableSlots<
    #[cfg(feature = "alloc")] Backing: StableSlotsBacking = AllocatedStableSlots,
    #[cfg(not(feature = "alloc"))] Backing: StableSlotsBacking,
> {
    maximum_rows: usize,
    row_to_slot: Backing::Rows,
    slot_locations: Backing::Locations,
    first_free: Option<StableSlot>,
}

impl<Backing: StableSlotsBacking> StableSlots<Backing> {
    pub const fn capacity(&self) -> usize {
        self.maximum_rows
    }
    pub fn is_empty(&self) -> bool {
        self.row_to_slot.is_empty()
    }
}

#[cfg(test)]
mod tests;