Skip to main content

winget_types/
manifest_type.rs

1use core::fmt;
2
3use icu_locale::LanguageIdentifier;
4
5/// The type of the manifest.
6#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
7#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
9pub enum ManifestType {
10    #[default]
11    Installer,
12    DefaultLocale,
13    Locale,
14    Version,
15}
16
17#[cfg(feature = "serde")]
18impl ManifestType {
19    pub(crate) const fn installer() -> Self {
20        Self::Installer
21    }
22
23    pub(crate) const fn default_locale() -> Self {
24        Self::DefaultLocale
25    }
26
27    pub(crate) const fn locale() -> Self {
28        Self::Locale
29    }
30
31    pub(crate) const fn version() -> Self {
32        Self::Version
33    }
34}
35
36impl fmt::Display for ManifestType {
37    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
38        match self {
39            Self::Installer => f.write_str("Installer"),
40            Self::DefaultLocale => f.write_str("DefaultLocale"),
41            Self::Locale => f.write_str("Locale"),
42            Self::Version => f.write_str("Version"),
43        }
44    }
45}
46
47#[derive(Clone, Debug, Eq, PartialEq, Hash)]
48pub enum ManifestTypeWithLocale {
49    Installer,
50    Locale(LanguageIdentifier),
51    Version,
52}