Skip to main content

imferno_core/assetmap/
volindex_codes.rs

1//! Typed validation-code catalogue for SMPTE ST 429-9 (VOLINDEX).
2
3use crate::diagnostics::codes::ValidationCode;
4use crate::diagnostics::{Category, Severity};
5
6/// Validation codes defined by SMPTE ST 429-9:2014 (Volume Index & AssetMap).
7#[derive(Debug, Clone, Copy, PartialEq, Eq, strum::EnumIter)]
8pub enum St429_9_2014 {
9    /// No volume-index document found in the package root.
10    VolindexMissing,
11    /// The VOLINDEX.xml document is not well-formed XML (ST 429-9:2014 §7).
12    MalformedXml,
13}
14
15impl ValidationCode for St429_9_2014 {
16    fn code(&self) -> &'static str {
17        match self {
18            Self::VolindexMissing => "ST429-9:2014:7/VolindexMissing",
19            Self::MalformedXml => "ST429-9:2014:7/MalformedXml",
20        }
21    }
22    fn description(&self) -> &'static str {
23        match self {
24            Self::VolindexMissing => "No volume-index document found in the package root.",
25            Self::MalformedXml => "The VOLINDEX.xml document is not well-formed XML.",
26        }
27    }
28    fn default_severity(&self) -> Severity {
29        match self {
30            Self::VolindexMissing => Severity::Info,
31            Self::MalformedXml => Severity::Error,
32        }
33    }
34    fn category(&self) -> Category {
35        Category::Structure
36    }
37    fn example(&self) -> Option<&'static str> {
38        Some(match self {
39            Self::VolindexMissing => {
40                "Package root contains ASSETMAP.xml and CPL/PKL XMLs but no VOLINDEX.xml."
41            }
42            Self::MalformedXml => {
43                "<VolumeIndex>1<!-- truncated --> — VOLINDEX.xml ends mid-element."
44            }
45        })
46    }
47}
48
49impl St429_9_2014 {
50    pub const ALL: &'static [Self] = &[Self::VolindexMissing, Self::MalformedXml];
51}
52
53impl From<St429_9_2014> for String {
54    fn from(c: St429_9_2014) -> String {
55        c.code().to_string()
56    }
57}