caco 0.5.33

library for dealing with doom [et al] wad files
Documentation
use crate::agnostic::Clump;

pub mod phantoms;
use phantoms::PhantomDirectory;

/// Either a [`Clump`] or a subdirectory. Subdirectories are not yet implemented.
pub trait Entity<C: Clump, D> {
    /// Whether the entity is a clump.
    fn is_clump(&self) -> bool;
    
    /// Gives [`Some`] with a borrow of the underlying clump if the entity is a clump, otherwise gives [`None`]
    fn take_clump(&self) -> Option<&C>;

    /// Whether the entity is a dir.
    fn is_dir(&self) -> bool;

    /// Gives [`Some`] with a borrow of the underlying dir if the entity is a dir, otherwise gives [`None`]
    fn take_dir(&self) -> Option<&D>;
}

impl<C: Clump> Entity<C, PhantomDirectory> for C {
    fn is_clump(&self) -> bool {
        true
    }

    fn take_clump(&self) -> Option<&C> {
        Some(self)
    }

    fn is_dir(&self) -> bool {
        false
    }

    fn take_dir(&self) -> Option<&PhantomDirectory> {
        None::<&PhantomDirectory>
    }
}