Skip to main content

sdsforge_core/
country.rs

1use crate::language::Language;
2
3/// Country/regulatory-region that governs the SDS requirements.
4///
5/// Used to select country-specific extraction rules, validation checks,
6/// and compliance-gap reporting.
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8pub enum SourceCountry {
9    Japan,
10    China,
11    Taiwan,
12    Korea,
13}
14
15impl SourceCountry {
16    /// Infer the most likely country from a detected language.
17    ///
18    /// English is ambiguous (US, EU, AU, …) and returns `None`.
19    /// The caller may override this inference with an explicit `--country` flag.
20    pub fn infer_from_language(lang: Language) -> Option<Self> {
21        match lang {
22            Language::Japanese => Some(Self::Japan),
23            Language::ChineseSimplified => Some(Self::China),
24            Language::ChineseTraditional => Some(Self::Taiwan),
25            Language::English => None,
26        }
27    }
28
29    /// Short English name used in log messages and report filenames.
30    pub fn name_en(self) -> &'static str {
31        match self {
32            Self::Japan  => "Japan",
33            Self::China  => "China",
34            Self::Taiwan => "Taiwan",
35            Self::Korea  => "Korea",
36        }
37    }
38
39    /// Primary regulatory standard governing SDS content for this country.
40    pub fn regulatory_standard(self) -> &'static str {
41        match self {
42            Self::Japan  => "JIS Z 7253 / MHLW",
43            Self::China  => "GB/T 16483-2008 / GB/T 17519-2013",
44            Self::Taiwan => "CNS 15030",
45            Self::Korea  => "K-GHS Rev.6 (산업안전보건법)",
46        }
47    }
48
49    /// Lowercase ASCII slug used in `_compliance_<slug>.json` filenames.
50    pub fn slug(self) -> &'static str {
51        match self {
52            Self::Japan  => "jp",
53            Self::China  => "cn",
54            Self::Taiwan => "tw",
55            Self::Korea  => "kr",
56        }
57    }
58}