caco 0.5.33

library for dealing with doom [et al] wad files
Documentation
use crate::agnostic::{Clump, Entity, FlatClod, phantoms::PhantomDirectory};

/// A container of many entities, which are each either [`Clump`]s - named bits of data - or
/// subdirectories containing more [`Clump`]s.
pub trait Clod<C: Clump, D> {
    /// Get the amount of entities.
    fn ent_amt(&self) -> usize;

    /// Borrow a single entity by number.
    fn nth_ent(&self, n: usize) -> &impl Entity<C, D>;

    //// Borrows many entities by numbers. The range may be non-contiguous. The returned entities are always
    /// in numerically increasing order, and are not duplicated, regardless of the ordering or
    /// overlapping of the provided range(s).
    fn a_sub_nth_ents(&self, a: impl Iterator<Item = usize>) -> Vec<&impl Entity<C, D>>;
}

impl<C: Clump, M: FlatClod<C>> Clod<C, PhantomDirectory> for M {
    fn ent_amt(&self) -> usize {
        self.clump_amt()
    }

    #[allow(refining_impl_trait)]
    fn nth_ent(&self, n: usize) -> &C {
        self.nth_clump(n)
    }

    #[allow(refining_impl_trait)]
    fn a_sub_nth_ents(&self, a: impl Iterator<Item = usize>) -> Vec<&C> {
        self.a_sub_nth_clumps(a)
    }
}