caco 0.5.33

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

/// The type of lump used in Quake's Wad2 format.
/// 
/// https://six-of-one.github.io/quake-specifications/qkspec_7.htm#CWAD0
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct QuakeLump {
    /// Name of the lump. Will be truncated to 8 characters.
    pub name: String,

    /// Raw data contained in the lump.
    pub data: Box<[u8]>,

    // quake-wad2-specific:
    
    /// Size of the lump after loaded into memory.
    pub memsize: u32,

    /// Type of data the lump stores:
    /// 
    /// '@' - Color palette
    /// 'B' - Status bar graphics
    /// 'D' - Mip texture(?)
    /// 'E' - Console graphics
    pub datatype: char,

    /// Encodes the type of compression used on the raw data.
    pub compression: char,
}

impl Clump for QuakeLump {
    fn name(&self) -> &String {
        &self.name
    }

    fn bytestuff(&self) -> &Box<[u8]> {
        &self.data
    }
}

impl ClumpMut for QuakeLump {
    fn rename(&mut self, s: impl AsRef<str>) {
        self.name = s.as_ref().to_string();
    }

    fn replace(&mut self, b: &[u8]) {
        self.data = b.into();
    }
}