#[non_exhaustive]
pub enum FileFormat {
    Csv,
    Unknown(UnknownVariantValue),
}
Expand description

When writing a match expression against FileFormat, it is important to ensure your code is forward-compatible. That is, if a match arm handles a case for a feature that is supported by the service but has not been represented as an enum variant in a current version of SDK, your code should continue to work when you upgrade SDK to a future version in which the enum does include a variant for that feature.

Here is an example of how you can make a match expression forward-compatible:

# let fileformat = unimplemented!();
match fileformat {
    FileFormat::Csv => { /* ... */ },
    other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
    _ => { /* ... */ },
}

The above code demonstrates that when fileformat represents NewFeature, the execution path will lead to the second last match arm, even though the enum does not contain a variant FileFormat::NewFeature in the current version of SDK. The reason is that the variable other, created by the @ operator, is bound to FileFormat::Unknown(UnknownVariantValue("NewFeature".to_owned())) and calling as_str on it yields "NewFeature". This match expression is forward-compatible when executed with a newer version of SDK where the variant FileFormat::NewFeature is defined. Specifically, when fileformat represents NewFeature, the execution path will hit the second last match arm as before by virtue of calling as_str on FileFormat::NewFeature also yielding "NewFeature".

Explicitly matching on the Unknown variant should be avoided for two reasons:

  • The inner data UnknownVariantValue is opaque, and no further information can be extracted.
  • It might inadvertently shadow other intended match arms.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Csv

§

Unknown(UnknownVariantValue)

Unknown contains new variants that have been added since this code was generated.

Implementations§

Returns the &str value of the enum member.

Examples found in repository?
src/model.rs (line 8403)
8402
8403
8404
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/json_ser.rs (line 111)
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
pub fn serialize_structure_crate_input_export_auto_scaling_group_recommendations_input(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::input::ExportAutoScalingGroupRecommendationsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_16) = &input.account_ids {
        let mut array_17 = object.key("accountIds").start_array();
        for item_18 in var_16 {
            {
                array_17.value().string(item_18.as_str());
            }
        }
        array_17.finish();
    }
    if let Some(var_19) = &input.filters {
        let mut array_20 = object.key("filters").start_array();
        for item_21 in var_19 {
            {
                #[allow(unused_mut)]
                let mut object_22 = array_20.value().start_object();
                crate::json_ser::serialize_structure_crate_model_filter(&mut object_22, item_21)?;
                object_22.finish();
            }
        }
        array_20.finish();
    }
    if let Some(var_23) = &input.fields_to_export {
        let mut array_24 = object.key("fieldsToExport").start_array();
        for item_25 in var_23 {
            {
                array_24.value().string(item_25.as_str());
            }
        }
        array_24.finish();
    }
    if let Some(var_26) = &input.s3_destination_config {
        #[allow(unused_mut)]
        let mut object_27 = object.key("s3DestinationConfig").start_object();
        crate::json_ser::serialize_structure_crate_model_s3_destination_config(
            &mut object_27,
            var_26,
        )?;
        object_27.finish();
    }
    if let Some(var_28) = &input.file_format {
        object.key("fileFormat").string(var_28.as_str());
    }
    if input.include_member_accounts {
        object
            .key("includeMemberAccounts")
            .boolean(input.include_member_accounts);
    }
    if let Some(var_29) = &input.recommendation_preferences {
        #[allow(unused_mut)]
        let mut object_30 = object.key("recommendationPreferences").start_object();
        crate::json_ser::serialize_structure_crate_model_recommendation_preferences(
            &mut object_30,
            var_29,
        )?;
        object_30.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_input_export_ebs_volume_recommendations_input(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::input::ExportEbsVolumeRecommendationsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_31) = &input.account_ids {
        let mut array_32 = object.key("accountIds").start_array();
        for item_33 in var_31 {
            {
                array_32.value().string(item_33.as_str());
            }
        }
        array_32.finish();
    }
    if let Some(var_34) = &input.filters {
        let mut array_35 = object.key("filters").start_array();
        for item_36 in var_34 {
            {
                #[allow(unused_mut)]
                let mut object_37 = array_35.value().start_object();
                crate::json_ser::serialize_structure_crate_model_ebs_filter(
                    &mut object_37,
                    item_36,
                )?;
                object_37.finish();
            }
        }
        array_35.finish();
    }
    if let Some(var_38) = &input.fields_to_export {
        let mut array_39 = object.key("fieldsToExport").start_array();
        for item_40 in var_38 {
            {
                array_39.value().string(item_40.as_str());
            }
        }
        array_39.finish();
    }
    if let Some(var_41) = &input.s3_destination_config {
        #[allow(unused_mut)]
        let mut object_42 = object.key("s3DestinationConfig").start_object();
        crate::json_ser::serialize_structure_crate_model_s3_destination_config(
            &mut object_42,
            var_41,
        )?;
        object_42.finish();
    }
    if let Some(var_43) = &input.file_format {
        object.key("fileFormat").string(var_43.as_str());
    }
    if input.include_member_accounts {
        object
            .key("includeMemberAccounts")
            .boolean(input.include_member_accounts);
    }
    Ok(())
}

pub fn serialize_structure_crate_input_export_ec2_instance_recommendations_input(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::input::ExportEc2InstanceRecommendationsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_44) = &input.account_ids {
        let mut array_45 = object.key("accountIds").start_array();
        for item_46 in var_44 {
            {
                array_45.value().string(item_46.as_str());
            }
        }
        array_45.finish();
    }
    if let Some(var_47) = &input.filters {
        let mut array_48 = object.key("filters").start_array();
        for item_49 in var_47 {
            {
                #[allow(unused_mut)]
                let mut object_50 = array_48.value().start_object();
                crate::json_ser::serialize_structure_crate_model_filter(&mut object_50, item_49)?;
                object_50.finish();
            }
        }
        array_48.finish();
    }
    if let Some(var_51) = &input.fields_to_export {
        let mut array_52 = object.key("fieldsToExport").start_array();
        for item_53 in var_51 {
            {
                array_52.value().string(item_53.as_str());
            }
        }
        array_52.finish();
    }
    if let Some(var_54) = &input.s3_destination_config {
        #[allow(unused_mut)]
        let mut object_55 = object.key("s3DestinationConfig").start_object();
        crate::json_ser::serialize_structure_crate_model_s3_destination_config(
            &mut object_55,
            var_54,
        )?;
        object_55.finish();
    }
    if let Some(var_56) = &input.file_format {
        object.key("fileFormat").string(var_56.as_str());
    }
    if input.include_member_accounts {
        object
            .key("includeMemberAccounts")
            .boolean(input.include_member_accounts);
    }
    if let Some(var_57) = &input.recommendation_preferences {
        #[allow(unused_mut)]
        let mut object_58 = object.key("recommendationPreferences").start_object();
        crate::json_ser::serialize_structure_crate_model_recommendation_preferences(
            &mut object_58,
            var_57,
        )?;
        object_58.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_input_export_lambda_function_recommendations_input(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::input::ExportLambdaFunctionRecommendationsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_59) = &input.account_ids {
        let mut array_60 = object.key("accountIds").start_array();
        for item_61 in var_59 {
            {
                array_60.value().string(item_61.as_str());
            }
        }
        array_60.finish();
    }
    if let Some(var_62) = &input.filters {
        let mut array_63 = object.key("filters").start_array();
        for item_64 in var_62 {
            {
                #[allow(unused_mut)]
                let mut object_65 = array_63.value().start_object();
                crate::json_ser::serialize_structure_crate_model_lambda_function_recommendation_filter(&mut object_65, item_64)?;
                object_65.finish();
            }
        }
        array_63.finish();
    }
    if let Some(var_66) = &input.fields_to_export {
        let mut array_67 = object.key("fieldsToExport").start_array();
        for item_68 in var_66 {
            {
                array_67.value().string(item_68.as_str());
            }
        }
        array_67.finish();
    }
    if let Some(var_69) = &input.s3_destination_config {
        #[allow(unused_mut)]
        let mut object_70 = object.key("s3DestinationConfig").start_object();
        crate::json_ser::serialize_structure_crate_model_s3_destination_config(
            &mut object_70,
            var_69,
        )?;
        object_70.finish();
    }
    if let Some(var_71) = &input.file_format {
        object.key("fileFormat").string(var_71.as_str());
    }
    if input.include_member_accounts {
        object
            .key("includeMemberAccounts")
            .boolean(input.include_member_accounts);
    }
    Ok(())
}

Returns all the &str values of the enum members.

Trait Implementations§

Converts this type into a shared reference of the (usually inferred) input type.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more