#[non_exhaustive]
pub enum CrUpdateAllocationStrategy {
    BestFitProgressive,
    SpotCapacityOptimized,
    Unknown(UnknownVariantValue),
}
Expand description

When writing a match expression against CrUpdateAllocationStrategy, 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 crupdateallocationstrategy = unimplemented!();
match crupdateallocationstrategy {
    CrUpdateAllocationStrategy::BestFitProgressive => { /* ... */ },
    CrUpdateAllocationStrategy::SpotCapacityOptimized => { /* ... */ },
    other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
    _ => { /* ... */ },
}

The above code demonstrates that when crupdateallocationstrategy represents NewFeature, the execution path will lead to the second last match arm, even though the enum does not contain a variant CrUpdateAllocationStrategy::NewFeature in the current version of SDK. The reason is that the variable other, created by the @ operator, is bound to CrUpdateAllocationStrategy::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 CrUpdateAllocationStrategy::NewFeature is defined. Specifically, when crupdateallocationstrategy represents NewFeature, the execution path will hit the second last match arm as before by virtue of calling as_str on CrUpdateAllocationStrategy::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.
§

BestFitProgressive

§

SpotCapacityOptimized

§

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 1583)
1582
1583
1584
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/json_ser.rs (line 1217)
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
pub fn serialize_structure_crate_model_compute_resource_update(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::ComputeResourceUpdate,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_268) = &input.minv_cpus {
        object.key("minvCpus").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_268).into()),
        );
    }
    if let Some(var_269) = &input.maxv_cpus {
        object.key("maxvCpus").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_269).into()),
        );
    }
    if let Some(var_270) = &input.desiredv_cpus {
        object.key("desiredvCpus").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_270).into()),
        );
    }
    if let Some(var_271) = &input.subnets {
        let mut array_272 = object.key("subnets").start_array();
        for item_273 in var_271 {
            {
                array_272.value().string(item_273.as_str());
            }
        }
        array_272.finish();
    }
    if let Some(var_274) = &input.security_group_ids {
        let mut array_275 = object.key("securityGroupIds").start_array();
        for item_276 in var_274 {
            {
                array_275.value().string(item_276.as_str());
            }
        }
        array_275.finish();
    }
    if let Some(var_277) = &input.allocation_strategy {
        object.key("allocationStrategy").string(var_277.as_str());
    }
    if let Some(var_278) = &input.instance_types {
        let mut array_279 = object.key("instanceTypes").start_array();
        for item_280 in var_278 {
            {
                array_279.value().string(item_280.as_str());
            }
        }
        array_279.finish();
    }
    if let Some(var_281) = &input.ec2_key_pair {
        object.key("ec2KeyPair").string(var_281.as_str());
    }
    if let Some(var_282) = &input.instance_role {
        object.key("instanceRole").string(var_282.as_str());
    }
    if let Some(var_283) = &input.tags {
        #[allow(unused_mut)]
        let mut object_284 = object.key("tags").start_object();
        for (key_285, value_286) in var_283 {
            {
                object_284.key(key_285.as_str()).string(value_286.as_str());
            }
        }
        object_284.finish();
    }
    if let Some(var_287) = &input.placement_group {
        object.key("placementGroup").string(var_287.as_str());
    }
    if let Some(var_288) = &input.bid_percentage {
        object.key("bidPercentage").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_288).into()),
        );
    }
    if let Some(var_289) = &input.launch_template {
        #[allow(unused_mut)]
        let mut object_290 = object.key("launchTemplate").start_object();
        crate::json_ser::serialize_structure_crate_model_launch_template_specification(
            &mut object_290,
            var_289,
        )?;
        object_290.finish();
    }
    if let Some(var_291) = &input.ec2_configuration {
        let mut array_292 = object.key("ec2Configuration").start_array();
        for item_293 in var_291 {
            {
                #[allow(unused_mut)]
                let mut object_294 = array_292.value().start_object();
                crate::json_ser::serialize_structure_crate_model_ec2_configuration(
                    &mut object_294,
                    item_293,
                )?;
                object_294.finish();
            }
        }
        array_292.finish();
    }
    if let Some(var_295) = &input.update_to_latest_image_version {
        object.key("updateToLatestImageVersion").boolean(*var_295);
    }
    if let Some(var_296) = &input.r#type {
        object.key("type").string(var_296.as_str());
    }
    if let Some(var_297) = &input.image_id {
        object.key("imageId").string(var_297.as_str());
    }
    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