//! ZCD archive format for Cord geometry.
//!
//! A `.zcd` file is a ZIP container that can hold any combination of:
//! - Cordial source (`.crd`)
//! - Serialized TrigGraph (`.trig`)
//! - WGSL shader
//! - CORDIC binary (`.cord`)
//!
//! A manifest tracks which layers are present.

pub mod read;
pub mod write;

use serde::{Deserialize, Serialize};

/// .crd = cordial source, .cord = CORDIC binary, .zcd = zipped cord archive
pub const ZCD_EXTENSION: &str = "zcd";
pub const CRD_EXTENSION: &str = "crd";
pub const CORD_EXTENSION: &str = "cord";

/// Manifest describing what layers are present in a .zcd file.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Manifest {
    pub version: u32,
    pub name: Option<String>,
    pub cordic_word_bits: Option<u8>,
    pub layers: Layers,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Layers {
    pub source: bool,
    pub trig: bool,
    pub shader: bool,
    pub cordic: bool,
    #[serde(default)]
    pub config: bool,
}

impl Default for Manifest {
    fn default() -> Self {
        Self {
            version: 1,
            name: None,
            cordic_word_bits: None,
            layers: Layers {
                source: false,
                trig: false,
                shader: false,
                cordic: false,
                config: false,
            },
        }
    }
}
