winget_types/locale/
moniker.rs1use core::{fmt, ops::Deref, str::FromStr};
2
3use super::{Tag, TagError};
4
5#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7#[cfg_attr(feature = "serde", serde(transparent))]
8#[repr(transparent)]
9pub struct Moniker(Tag);
10
11impl Moniker {
12 #[inline]
14 pub fn as_str(&self) -> &str {
15 self.0.as_str()
16 }
17}
18
19impl AsRef<str> for Moniker {
20 fn as_ref(&self) -> &str {
21 self.0.as_ref()
22 }
23}
24
25impl Deref for Moniker {
26 type Target = Tag;
27
28 fn deref(&self) -> &Self::Target {
29 &self.0
30 }
31}
32
33impl fmt::Display for Moniker {
34 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35 self.0.fmt(f)
36 }
37}
38
39impl FromStr for Moniker {
40 type Err = TagError;
41
42 fn from_str(s: &str) -> Result<Self, Self::Err> {
43 Tag::from_str(s).map(Self)
44 }
45}