7 7 | /// upgrade SDK to a future version in which the enum does include a variant for that
|
8 8 | /// feature.
|
9 9 | ///
|
10 10 | /// Here is an example of how you can make a match expression forward-compatible:
|
11 11 | ///
|
12 12 | /// ```text
|
13 13 | /// # let objectstorageclass = unimplemented!();
|
14 14 | /// match objectstorageclass {
|
15 15 | /// ObjectStorageClass::DeepArchive => { /* ... */ },
|
16 16 | /// ObjectStorageClass::ExpressOnezone => { /* ... */ },
|
17 - | /// ObjectStorageClass::FsxOpenzfs => { /* ... */ },
|
18 17 | /// ObjectStorageClass::Glacier => { /* ... */ },
|
19 18 | /// ObjectStorageClass::GlacierIr => { /* ... */ },
|
20 19 | /// ObjectStorageClass::IntelligentTiering => { /* ... */ },
|
21 20 | /// ObjectStorageClass::OnezoneIa => { /* ... */ },
|
22 21 | /// ObjectStorageClass::Outposts => { /* ... */ },
|
23 22 | /// ObjectStorageClass::ReducedRedundancy => { /* ... */ },
|
24 23 | /// ObjectStorageClass::Snow => { /* ... */ },
|
25 24 | /// ObjectStorageClass::Standard => { /* ... */ },
|
26 25 | /// ObjectStorageClass::StandardIa => { /* ... */ },
|
27 26 | /// other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
|
28 27 | /// _ => { /* ... */ },
|
29 28 | /// }
|
30 29 | /// ```
|
31 30 | /// The above code demonstrates that when `objectstorageclass` represents
|
32 31 | /// `NewFeature`, the execution path will lead to the second last match arm,
|
33 32 | /// even though the enum does not contain a variant `ObjectStorageClass::NewFeature`
|
34 33 | /// in the current version of SDK. The reason is that the variable `other`,
|
35 34 | /// created by the `@` operator, is bound to
|
36 35 | /// `ObjectStorageClass::Unknown(UnknownVariantValue("NewFeature".to_owned()))`
|
37 36 | /// and calling `as_str` on it yields `"NewFeature"`.
|
38 37 | /// This match expression is forward-compatible when executed with a newer
|
39 38 | /// version of SDK where the variant `ObjectStorageClass::NewFeature` is defined.
|
40 39 | /// Specifically, when `objectstorageclass` represents `NewFeature`,
|
41 40 | /// the execution path will hit the second last match arm as before by virtue of
|
42 41 | /// calling `as_str` on `ObjectStorageClass::NewFeature` also yielding `"NewFeature"`.
|
43 42 | ///
|
44 43 | /// Explicitly matching on the `Unknown` variant should
|
45 44 | /// be avoided for two reasons:
|
46 45 | /// - The inner data `UnknownVariantValue` is opaque, and no further information can be extracted.
|
47 46 | /// - It might inadvertently shadow other intended match arms.
|
48 47 | ///
|
49 48 | #[allow(missing_docs)] // documentation missing in model
|
50 49 | #[non_exhaustive]
|
51 50 | #[derive(
|
52 51 | ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
|
53 52 | )]
|
54 53 | pub enum ObjectStorageClass {
|
55 54 | #[allow(missing_docs)] // documentation missing in model
|
56 55 | DeepArchive,
|
57 56 | #[allow(missing_docs)] // documentation missing in model
|
58 57 | ExpressOnezone,
|
59 58 | #[allow(missing_docs)] // documentation missing in model
|
60 - | FsxOpenzfs,
|
61 - | #[allow(missing_docs)] // documentation missing in model
|
62 59 | Glacier,
|
63 60 | #[allow(missing_docs)] // documentation missing in model
|
64 61 | GlacierIr,
|
65 62 | #[allow(missing_docs)] // documentation missing in model
|
66 63 | IntelligentTiering,
|
67 64 | #[allow(missing_docs)] // documentation missing in model
|
68 65 | OnezoneIa,
|
69 66 | #[allow(missing_docs)] // documentation missing in model
|
70 67 | Outposts,
|
71 68 | #[allow(missing_docs)] // documentation missing in model
|
72 69 | ReducedRedundancy,
|
73 70 | #[allow(missing_docs)] // documentation missing in model
|
74 71 | Snow,
|
75 72 | #[allow(missing_docs)] // documentation missing in model
|
76 73 | Standard,
|
77 74 | #[allow(missing_docs)] // documentation missing in model
|
78 75 | StandardIa,
|
79 76 | /// `Unknown` contains new variants that have been added since this code was generated.
|
80 77 | #[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
|
81 78 | Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
|
82 79 | }
|
83 80 | impl ::std::convert::From<&str> for ObjectStorageClass {
|
84 81 | fn from(s: &str) -> Self {
|
85 82 | match s {
|
86 83 | "DEEP_ARCHIVE" => ObjectStorageClass::DeepArchive,
|
87 84 | "EXPRESS_ONEZONE" => ObjectStorageClass::ExpressOnezone,
|
88 - | "FSX_OPENZFS" => ObjectStorageClass::FsxOpenzfs,
|
89 85 | "GLACIER" => ObjectStorageClass::Glacier,
|
90 86 | "GLACIER_IR" => ObjectStorageClass::GlacierIr,
|
91 87 | "INTELLIGENT_TIERING" => ObjectStorageClass::IntelligentTiering,
|
92 88 | "ONEZONE_IA" => ObjectStorageClass::OnezoneIa,
|
93 89 | "OUTPOSTS" => ObjectStorageClass::Outposts,
|
94 90 | "REDUCED_REDUNDANCY" => ObjectStorageClass::ReducedRedundancy,
|
95 91 | "SNOW" => ObjectStorageClass::Snow,
|
96 92 | "STANDARD" => ObjectStorageClass::Standard,
|
97 93 | "STANDARD_IA" => ObjectStorageClass::StandardIa,
|
98 94 | other => ObjectStorageClass::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
|
99 95 | }
|
100 96 | }
|
101 97 | }
|
102 98 | impl ::std::str::FromStr for ObjectStorageClass {
|
103 99 | type Err = ::std::convert::Infallible;
|
104 100 |
|
105 101 | fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
|
106 102 | ::std::result::Result::Ok(ObjectStorageClass::from(s))
|
107 103 | }
|
108 104 | }
|
109 105 | impl ObjectStorageClass {
|
110 106 | /// Returns the `&str` value of the enum member.
|
111 107 | pub fn as_str(&self) -> &str {
|
112 108 | match self {
|
113 109 | ObjectStorageClass::DeepArchive => "DEEP_ARCHIVE",
|
114 110 | ObjectStorageClass::ExpressOnezone => "EXPRESS_ONEZONE",
|
115 - | ObjectStorageClass::FsxOpenzfs => "FSX_OPENZFS",
|
116 111 | ObjectStorageClass::Glacier => "GLACIER",
|
117 112 | ObjectStorageClass::GlacierIr => "GLACIER_IR",
|
118 113 | ObjectStorageClass::IntelligentTiering => "INTELLIGENT_TIERING",
|
119 114 | ObjectStorageClass::OnezoneIa => "ONEZONE_IA",
|
120 115 | ObjectStorageClass::Outposts => "OUTPOSTS",
|
121 116 | ObjectStorageClass::ReducedRedundancy => "REDUCED_REDUNDANCY",
|
122 117 | ObjectStorageClass::Snow => "SNOW",
|
123 118 | ObjectStorageClass::Standard => "STANDARD",
|
124 119 | ObjectStorageClass::StandardIa => "STANDARD_IA",
|
125 120 | ObjectStorageClass::Unknown(value) => value.as_str(),
|
126 121 | }
|
127 122 | }
|
128 123 | /// Returns all the `&str` representations of the enum members.
|
129 124 | pub const fn values() -> &'static [&'static str] {
|
130 125 | &[
|
131 126 | "DEEP_ARCHIVE",
|
132 127 | "EXPRESS_ONEZONE",
|
133 - | "FSX_OPENZFS",
|
134 128 | "GLACIER",
|
135 129 | "GLACIER_IR",
|
136 130 | "INTELLIGENT_TIERING",
|
137 131 | "ONEZONE_IA",
|
138 132 | "OUTPOSTS",
|
139 133 | "REDUCED_REDUNDANCY",
|
140 134 | "SNOW",
|
141 135 | "STANDARD",
|
142 136 | "STANDARD_IA",
|
143 137 | ]
|
144 138 | }
|
145 139 | }
|
146 140 | impl ::std::convert::AsRef<str> for ObjectStorageClass {
|
147 141 | fn as_ref(&self) -> &str {
|
148 142 | self.as_str()
|
149 143 | }
|
150 144 | }
|
151 145 | impl ObjectStorageClass {
|
152 146 | /// Parses the enum value while disallowing unknown variants.
|
153 147 | ///
|
154 148 | /// Unknown variants will result in an error.
|
155 149 | pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
|
156 150 | match Self::from(value) {
|
157 151 | #[allow(deprecated)]
|
158 152 | Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
|
159 153 | known => Ok(known),
|
160 154 | }
|
161 155 | }
|
162 156 | }
|
163 157 | impl ::std::fmt::Display for ObjectStorageClass {
|
164 158 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
165 159 | match self {
|
166 160 | ObjectStorageClass::DeepArchive => write!(f, "DEEP_ARCHIVE"),
|
167 161 | ObjectStorageClass::ExpressOnezone => write!(f, "EXPRESS_ONEZONE"),
|
168 - | ObjectStorageClass::FsxOpenzfs => write!(f, "FSX_OPENZFS"),
|
169 162 | ObjectStorageClass::Glacier => write!(f, "GLACIER"),
|
170 163 | ObjectStorageClass::GlacierIr => write!(f, "GLACIER_IR"),
|
171 164 | ObjectStorageClass::IntelligentTiering => write!(f, "INTELLIGENT_TIERING"),
|
172 165 | ObjectStorageClass::OnezoneIa => write!(f, "ONEZONE_IA"),
|
173 166 | ObjectStorageClass::Outposts => write!(f, "OUTPOSTS"),
|
174 167 | ObjectStorageClass::ReducedRedundancy => write!(f, "REDUCED_REDUNDANCY"),
|
175 168 | ObjectStorageClass::Snow => write!(f, "SNOW"),
|
176 169 | ObjectStorageClass::Standard => write!(f, "STANDARD"),
|
177 170 | ObjectStorageClass::StandardIa => write!(f, "STANDARD_IA"),
|
178 171 | ObjectStorageClass::Unknown(value) => write!(f, "{value}"),
|