1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + |
|
3 + | /// When writing a match expression against `PatchFilterKey`, it is important to ensure
|
4 + | /// your code is forward-compatible. That is, if a match arm handles a case for a
|
5 + | /// feature that is supported by the service but has not been represented as an enum
|
6 + | /// variant in a current version of SDK, your code should continue to work when you
|
7 + | /// upgrade SDK to a future version in which the enum does include a variant for that
|
8 + | /// feature.
|
9 + | ///
|
10 + | /// Here is an example of how you can make a match expression forward-compatible:
|
11 + | ///
|
12 + | /// ```text
|
13 + | /// # let patchfilterkey = unimplemented!();
|
14 + | /// match patchfilterkey {
|
15 + | /// PatchFilterKey::AdvisoryId => { /* ... */ },
|
16 + | /// PatchFilterKey::Arch => { /* ... */ },
|
17 + | /// PatchFilterKey::BugzillaId => { /* ... */ },
|
18 + | /// PatchFilterKey::Classification => { /* ... */ },
|
19 + | /// PatchFilterKey::CveId => { /* ... */ },
|
20 + | /// PatchFilterKey::Epoch => { /* ... */ },
|
21 + | /// PatchFilterKey::MsrcSeverity => { /* ... */ },
|
22 + | /// PatchFilterKey::Name => { /* ... */ },
|
23 + | /// PatchFilterKey::PatchId => { /* ... */ },
|
24 + | /// PatchFilterKey::PatchSet => { /* ... */ },
|
25 + | /// PatchFilterKey::Priority => { /* ... */ },
|
26 + | /// PatchFilterKey::Product => { /* ... */ },
|
27 + | /// PatchFilterKey::ProductFamily => { /* ... */ },
|
28 + | /// PatchFilterKey::Release => { /* ... */ },
|
29 + | /// PatchFilterKey::Repository => { /* ... */ },
|
30 + | /// PatchFilterKey::Section => { /* ... */ },
|
31 + | /// PatchFilterKey::Security => { /* ... */ },
|
32 + | /// PatchFilterKey::Severity => { /* ... */ },
|
33 + | /// PatchFilterKey::Version => { /* ... */ },
|
34 + | /// other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
|
35 + | /// _ => { /* ... */ },
|
36 + | /// }
|
37 + | /// ```
|
38 + | /// The above code demonstrates that when `patchfilterkey` represents
|
39 + | /// `NewFeature`, the execution path will lead to the second last match arm,
|
40 + | /// even though the enum does not contain a variant `PatchFilterKey::NewFeature`
|
41 + | /// in the current version of SDK. The reason is that the variable `other`,
|
42 + | /// created by the `@` operator, is bound to
|
43 + | /// `PatchFilterKey::Unknown(UnknownVariantValue("NewFeature".to_owned()))`
|
44 + | /// and calling `as_str` on it yields `"NewFeature"`.
|
45 + | /// This match expression is forward-compatible when executed with a newer
|
46 + | /// version of SDK where the variant `PatchFilterKey::NewFeature` is defined.
|
47 + | /// Specifically, when `patchfilterkey` represents `NewFeature`,
|
48 + | /// the execution path will hit the second last match arm as before by virtue of
|
49 + | /// calling `as_str` on `PatchFilterKey::NewFeature` also yielding `"NewFeature"`.
|
50 + | ///
|
51 + | /// Explicitly matching on the `Unknown` variant should
|
52 + | /// be avoided for two reasons:
|
53 + | /// - The inner data `UnknownVariantValue` is opaque, and no further information can be extracted.
|
54 + | /// - It might inadvertently shadow other intended match arms.
|
55 + | ///
|
56 + | #[allow(missing_docs)] // documentation missing in model
|
57 + | #[non_exhaustive]
|
58 + | #[derive(
|
59 + | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
|
60 + | )]
|
61 + | pub enum PatchFilterKey {
|
62 + | #[allow(missing_docs)] // documentation missing in model
|
63 + | AdvisoryId,
|
64 + | #[allow(missing_docs)] // documentation missing in model
|
65 + | Arch,
|
66 + | #[allow(missing_docs)] // documentation missing in model
|
67 + | BugzillaId,
|
68 + | #[allow(missing_docs)] // documentation missing in model
|
69 + | Classification,
|
70 + | #[allow(missing_docs)] // documentation missing in model
|
71 + | CveId,
|
72 + | #[allow(missing_docs)] // documentation missing in model
|
73 + | Epoch,
|
74 + | #[allow(missing_docs)] // documentation missing in model
|
75 + | MsrcSeverity,
|
76 + | #[allow(missing_docs)] // documentation missing in model
|
77 + | Name,
|
78 + | #[allow(missing_docs)] // documentation missing in model
|
79 + | PatchId,
|
80 + | #[allow(missing_docs)] // documentation missing in model
|
81 + | PatchSet,
|
82 + | #[allow(missing_docs)] // documentation missing in model
|
83 + | Priority,
|
84 + | #[allow(missing_docs)] // documentation missing in model
|
85 + | Product,
|
86 + | #[allow(missing_docs)] // documentation missing in model
|
87 + | ProductFamily,
|
88 + | #[allow(missing_docs)] // documentation missing in model
|
89 + | Release,
|
90 + | #[allow(missing_docs)] // documentation missing in model
|
91 + | Repository,
|
92 + | #[allow(missing_docs)] // documentation missing in model
|
93 + | Section,
|
94 + | #[allow(missing_docs)] // documentation missing in model
|
95 + | Security,
|
96 + | #[allow(missing_docs)] // documentation missing in model
|
97 + | Severity,
|
98 + | #[allow(missing_docs)] // documentation missing in model
|
99 + | Version,
|
100 + | /// `Unknown` contains new variants that have been added since this code was generated.
|
101 + | #[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
|
102 + | Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
|
103 + | }
|
104 + | impl ::std::convert::From<&str> for PatchFilterKey {
|
105 + | fn from(s: &str) -> Self {
|
106 + | match s {
|
107 + | "ADVISORY_ID" => PatchFilterKey::AdvisoryId,
|
108 + | "ARCH" => PatchFilterKey::Arch,
|
109 + | "BUGZILLA_ID" => PatchFilterKey::BugzillaId,
|
110 + | "CLASSIFICATION" => PatchFilterKey::Classification,
|
111 + | "CVE_ID" => PatchFilterKey::CveId,
|
112 + | "EPOCH" => PatchFilterKey::Epoch,
|
113 + | "MSRC_SEVERITY" => PatchFilterKey::MsrcSeverity,
|
114 + | "NAME" => PatchFilterKey::Name,
|
115 + | "PATCH_ID" => PatchFilterKey::PatchId,
|
116 + | "PATCH_SET" => PatchFilterKey::PatchSet,
|
117 + | "PRIORITY" => PatchFilterKey::Priority,
|
118 + | "PRODUCT" => PatchFilterKey::Product,
|
119 + | "PRODUCT_FAMILY" => PatchFilterKey::ProductFamily,
|
120 + | "RELEASE" => PatchFilterKey::Release,
|
121 + | "REPOSITORY" => PatchFilterKey::Repository,
|
122 + | "SECTION" => PatchFilterKey::Section,
|
123 + | "SECURITY" => PatchFilterKey::Security,
|
124 + | "SEVERITY" => PatchFilterKey::Severity,
|
125 + | "VERSION" => PatchFilterKey::Version,
|
126 + | other => PatchFilterKey::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
|
127 + | }
|
128 + | }
|
129 + | }
|
130 + | impl ::std::str::FromStr for PatchFilterKey {
|
131 + | type Err = ::std::convert::Infallible;
|
132 + |
|
133 + | fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
|
134 + | ::std::result::Result::Ok(PatchFilterKey::from(s))
|
135 + | }
|
136 + | }
|
137 + | impl PatchFilterKey {
|
138 + | /// Returns the `&str` value of the enum member.
|
139 + | pub fn as_str(&self) -> &str {
|
140 + | match self {
|
141 + | PatchFilterKey::AdvisoryId => "ADVISORY_ID",
|
142 + | PatchFilterKey::Arch => "ARCH",
|
143 + | PatchFilterKey::BugzillaId => "BUGZILLA_ID",
|
144 + | PatchFilterKey::Classification => "CLASSIFICATION",
|
145 + | PatchFilterKey::CveId => "CVE_ID",
|
146 + | PatchFilterKey::Epoch => "EPOCH",
|
147 + | PatchFilterKey::MsrcSeverity => "MSRC_SEVERITY",
|
148 + | PatchFilterKey::Name => "NAME",
|
149 + | PatchFilterKey::PatchId => "PATCH_ID",
|
150 + | PatchFilterKey::PatchSet => "PATCH_SET",
|
151 + | PatchFilterKey::Priority => "PRIORITY",
|
152 + | PatchFilterKey::Product => "PRODUCT",
|
153 + | PatchFilterKey::ProductFamily => "PRODUCT_FAMILY",
|
154 + | PatchFilterKey::Release => "RELEASE",
|
155 + | PatchFilterKey::Repository => "REPOSITORY",
|
156 + | PatchFilterKey::Section => "SECTION",
|
157 + | PatchFilterKey::Security => "SECURITY",
|
158 + | PatchFilterKey::Severity => "SEVERITY",
|
159 + | PatchFilterKey::Version => "VERSION",
|
160 + | PatchFilterKey::Unknown(value) => value.as_str(),
|
161 + | }
|
162 + | }
|
163 + | /// Returns all the `&str` representations of the enum members.
|
164 + | pub const fn values() -> &'static [&'static str] {
|
165 + | &[
|
166 + | "ADVISORY_ID",
|
167 + | "ARCH",
|
168 + | "BUGZILLA_ID",
|
169 + | "CLASSIFICATION",
|
170 + | "CVE_ID",
|
171 + | "EPOCH",
|
172 + | "MSRC_SEVERITY",
|
173 + | "NAME",
|
174 + | "PATCH_ID",
|
175 + | "PATCH_SET",
|
176 + | "PRIORITY",
|
177 + | "PRODUCT",
|
178 + | "PRODUCT_FAMILY",
|
179 + | "RELEASE",
|
180 + | "REPOSITORY",
|
181 + | "SECTION",
|
182 + | "SECURITY",
|
183 + | "SEVERITY",
|
184 + | "VERSION",
|
185 + | ]
|
186 + | }
|
187 + | }
|
188 + | impl ::std::convert::AsRef<str> for PatchFilterKey {
|
189 + | fn as_ref(&self) -> &str {
|
190 + | self.as_str()
|
191 + | }
|
192 + | }
|
193 + | impl PatchFilterKey {
|
194 + | /// Parses the enum value while disallowing unknown variants.
|
195 + | ///
|
196 + | /// Unknown variants will result in an error.
|
197 + | pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
|
198 + | match Self::from(value) {
|
199 + | #[allow(deprecated)]
|
200 + | Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
|
201 + | known => Ok(known),
|
202 + | }
|
203 + | }
|
204 + | }
|
205 + | impl ::std::fmt::Display for PatchFilterKey {
|
206 + | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
207 + | match self {
|
208 + | PatchFilterKey::AdvisoryId => write!(f, "ADVISORY_ID"),
|
209 + | PatchFilterKey::Arch => write!(f, "ARCH"),
|
210 + | PatchFilterKey::BugzillaId => write!(f, "BUGZILLA_ID"),
|
211 + | PatchFilterKey::Classification => write!(f, "CLASSIFICATION"),
|
212 + | PatchFilterKey::CveId => write!(f, "CVE_ID"),
|
213 + | PatchFilterKey::Epoch => write!(f, "EPOCH"),
|
214 + | PatchFilterKey::MsrcSeverity => write!(f, "MSRC_SEVERITY"),
|
215 + | PatchFilterKey::Name => write!(f, "NAME"),
|
216 + | PatchFilterKey::PatchId => write!(f, "PATCH_ID"),
|
217 + | PatchFilterKey::PatchSet => write!(f, "PATCH_SET"),
|
218 + | PatchFilterKey::Priority => write!(f, "PRIORITY"),
|
219 + | PatchFilterKey::Product => write!(f, "PRODUCT"),
|
220 + | PatchFilterKey::ProductFamily => write!(f, "PRODUCT_FAMILY"),
|
221 + | PatchFilterKey::Release => write!(f, "RELEASE"),
|
222 + | PatchFilterKey::Repository => write!(f, "REPOSITORY"),
|
223 + | PatchFilterKey::Section => write!(f, "SECTION"),
|
224 + | PatchFilterKey::Security => write!(f, "SECURITY"),
|
225 + | PatchFilterKey::Severity => write!(f, "SEVERITY"),
|
226 + | PatchFilterKey::Version => write!(f, "VERSION"),
|
227 + | PatchFilterKey::Unknown(value) => write!(f, "{value}"),
|
228 + | }
|
229 + | }
|
230 + | }
|