winget_types/shared/
manifest_type.rs

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