winget_types/installer/switches/
silent.rs1use core::{
2 fmt,
3 ops::{Deref, DerefMut},
4 str::FromStr,
5};
6
7use compact_str::CompactString;
8
9use super::switch::{InstallerSwitch, SwitchError};
10
11#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
12#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
13pub struct SilentSwitch(InstallerSwitch<512>);
14
15impl SilentSwitch {
16 #[inline]
17 pub fn iter(&self) -> core::slice::Iter<'_, CompactString> {
18 self.0.iter()
19 }
20}
21
22impl Deref for SilentSwitch {
23 type Target = InstallerSwitch<512>;
24
25 #[inline]
26 fn deref(&self) -> &Self::Target {
27 &self.0
28 }
29}
30
31impl DerefMut for SilentSwitch {
32 #[inline]
33 fn deref_mut(&mut self) -> &mut Self::Target {
34 &mut self.0
35 }
36}
37
38impl fmt::Display for SilentSwitch {
39 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40 self.0.fmt(f)
41 }
42}
43
44impl FromStr for SilentSwitch {
45 type Err = SwitchError<512>;
46
47 fn from_str(s: &str) -> Result<Self, Self::Err> {
48 InstallerSwitch::<512>::from_str(s).map(Self)
49 }
50}
51
52impl IntoIterator for SilentSwitch {
53 type Item = CompactString;
54
55 type IntoIter = smallvec::IntoIter<[CompactString; 2]>;
56
57 #[inline]
58 fn into_iter(self) -> Self::IntoIter {
59 self.0.into_iter()
60 }
61}
62
63impl<'switch> IntoIterator for &'switch SilentSwitch {
64 type Item = &'switch CompactString;
65
66 type IntoIter = core::slice::Iter<'switch, CompactString>;
67
68 #[inline]
69 fn into_iter(self) -> Self::IntoIter {
70 self.0.iter()
71 }
72}