#[non_exhaustive]
pub enum ArchitectureValues {
    Arm64,
    I386,
    X8664,
    X8664Mac,
    Unknown(UnknownVariantValue),
}
Expand description

When writing a match expression against ArchitectureValues, 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 architecturevalues = unimplemented!();
match architecturevalues {
    ArchitectureValues::Arm64 => { /* ... */ },
    ArchitectureValues::I386 => { /* ... */ },
    ArchitectureValues::X8664 => { /* ... */ },
    ArchitectureValues::X8664Mac => { /* ... */ },
    other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
    _ => { /* ... */ },
}

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

Arm64

§

I386

§

X8664

§

X8664Mac

§

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 14433)
14432
14433
14434
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/query_ser.rs (line 1990)
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
pub fn serialize_structure_crate_model_import_instance_launch_specification(
    mut writer: aws_smithy_query::QueryValueWriter,
    input: &crate::model::ImportInstanceLaunchSpecification,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    #[allow(unused_mut)]
    let mut scope_563 = writer.prefix("AdditionalInfo");
    if let Some(var_564) = &input.additional_info {
        scope_563.string(var_564);
    }
    #[allow(unused_mut)]
    let mut scope_565 = writer.prefix("Architecture");
    if let Some(var_566) = &input.architecture {
        scope_565.string(var_566.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_567 = writer.prefix("GroupId");
    if let Some(var_568) = &input.group_ids {
        let mut list_570 = scope_567.start_list(true, Some("SecurityGroupId"));
        for item_569 in var_568 {
            #[allow(unused_mut)]
            let mut entry_571 = list_570.entry();
            entry_571.string(item_569);
        }
        list_570.finish();
    }
    #[allow(unused_mut)]
    let mut scope_572 = writer.prefix("GroupName");
    if let Some(var_573) = &input.group_names {
        let mut list_575 = scope_572.start_list(true, Some("SecurityGroup"));
        for item_574 in var_573 {
            #[allow(unused_mut)]
            let mut entry_576 = list_575.entry();
            entry_576.string(item_574);
        }
        list_575.finish();
    }
    #[allow(unused_mut)]
    let mut scope_577 = writer.prefix("InstanceInitiatedShutdownBehavior");
    if let Some(var_578) = &input.instance_initiated_shutdown_behavior {
        scope_577.string(var_578.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_579 = writer.prefix("InstanceType");
    if let Some(var_580) = &input.instance_type {
        scope_579.string(var_580.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_581 = writer.prefix("Monitoring");
    if let Some(var_582) = &input.monitoring {
        scope_581.boolean(*var_582);
    }
    #[allow(unused_mut)]
    let mut scope_583 = writer.prefix("Placement");
    if let Some(var_584) = &input.placement {
        crate::query_ser::serialize_structure_crate_model_placement(scope_583, var_584)?;
    }
    #[allow(unused_mut)]
    let mut scope_585 = writer.prefix("PrivateIpAddress");
    if let Some(var_586) = &input.private_ip_address {
        scope_585.string(var_586);
    }
    #[allow(unused_mut)]
    let mut scope_587 = writer.prefix("SubnetId");
    if let Some(var_588) = &input.subnet_id {
        scope_587.string(var_588);
    }
    #[allow(unused_mut)]
    let mut scope_589 = writer.prefix("UserData");
    if let Some(var_590) = &input.user_data {
        crate::query_ser::serialize_structure_crate_model_user_data(scope_589, var_590)?;
    }
    Ok(())
}
src/operation_ser.rs (line 20214)
20200
20201
20202
20203
20204
20205
20206
20207
20208
20209
20210
20211
20212
20213
20214
20215
20216
20217
20218
20219
20220
20221
20222
20223
20224
20225
20226
20227
20228
20229
20230
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243
20244
20245
20246
20247
20248
20249
20250
20251
20252
20253
20254
20255
20256
20257
20258
20259
20260
20261
20262
20263
20264
20265
20266
20267
20268
20269
20270
20271
20272
20273
20274
20275
20276
20277
20278
20279
20280
20281
20282
20283
20284
20285
20286
20287
20288
20289
20290
20291
20292
20293
20294
20295
20296
20297
20298
20299
20300
20301
20302
20303
20304
20305
20306
20307
pub fn serialize_operation_crate_operation_register_image(
    input: &crate::input::RegisterImageInput,
) -> Result<aws_smithy_http::body::SdkBody, aws_smithy_http::operation::error::SerializationError> {
    let mut out = String::new();
    #[allow(unused_mut)]
    let mut writer = aws_smithy_query::QueryWriter::new(&mut out, "RegisterImage", "2016-11-15");
    #[allow(unused_mut)]
    let mut scope_5692 = writer.prefix("ImageLocation");
    if let Some(var_5693) = &input.image_location {
        scope_5692.string(var_5693);
    }
    #[allow(unused_mut)]
    let mut scope_5694 = writer.prefix("Architecture");
    if let Some(var_5695) = &input.architecture {
        scope_5694.string(var_5695.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_5696 = writer.prefix("BlockDeviceMapping");
    if let Some(var_5697) = &input.block_device_mappings {
        let mut list_5699 = scope_5696.start_list(true, Some("BlockDeviceMapping"));
        for item_5698 in var_5697 {
            #[allow(unused_mut)]
            let mut entry_5700 = list_5699.entry();
            crate::query_ser::serialize_structure_crate_model_block_device_mapping(
                entry_5700, item_5698,
            )?;
        }
        list_5699.finish();
    }
    #[allow(unused_mut)]
    let mut scope_5701 = writer.prefix("Description");
    if let Some(var_5702) = &input.description {
        scope_5701.string(var_5702);
    }
    #[allow(unused_mut)]
    let mut scope_5703 = writer.prefix("DryRun");
    if let Some(var_5704) = &input.dry_run {
        scope_5703.boolean(*var_5704);
    }
    #[allow(unused_mut)]
    let mut scope_5705 = writer.prefix("EnaSupport");
    if let Some(var_5706) = &input.ena_support {
        scope_5705.boolean(*var_5706);
    }
    #[allow(unused_mut)]
    let mut scope_5707 = writer.prefix("KernelId");
    if let Some(var_5708) = &input.kernel_id {
        scope_5707.string(var_5708);
    }
    #[allow(unused_mut)]
    let mut scope_5709 = writer.prefix("Name");
    if let Some(var_5710) = &input.name {
        scope_5709.string(var_5710);
    }
    #[allow(unused_mut)]
    let mut scope_5711 = writer.prefix("BillingProduct");
    if let Some(var_5712) = &input.billing_products {
        let mut list_5714 = scope_5711.start_list(true, Some("item"));
        for item_5713 in var_5712 {
            #[allow(unused_mut)]
            let mut entry_5715 = list_5714.entry();
            entry_5715.string(item_5713);
        }
        list_5714.finish();
    }
    #[allow(unused_mut)]
    let mut scope_5716 = writer.prefix("RamdiskId");
    if let Some(var_5717) = &input.ramdisk_id {
        scope_5716.string(var_5717);
    }
    #[allow(unused_mut)]
    let mut scope_5718 = writer.prefix("RootDeviceName");
    if let Some(var_5719) = &input.root_device_name {
        scope_5718.string(var_5719);
    }
    #[allow(unused_mut)]
    let mut scope_5720 = writer.prefix("SriovNetSupport");
    if let Some(var_5721) = &input.sriov_net_support {
        scope_5720.string(var_5721);
    }
    #[allow(unused_mut)]
    let mut scope_5722 = writer.prefix("VirtualizationType");
    if let Some(var_5723) = &input.virtualization_type {
        scope_5722.string(var_5723);
    }
    #[allow(unused_mut)]
    let mut scope_5724 = writer.prefix("BootMode");
    if let Some(var_5725) = &input.boot_mode {
        scope_5724.string(var_5725.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_5726 = writer.prefix("TpmSupport");
    if let Some(var_5727) = &input.tpm_support {
        scope_5726.string(var_5727.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_5728 = writer.prefix("UefiData");
    if let Some(var_5729) = &input.uefi_data {
        scope_5728.string(var_5729);
    }
    #[allow(unused_mut)]
    let mut scope_5730 = writer.prefix("ImdsSupport");
    if let Some(var_5731) = &input.imds_support {
        scope_5730.string(var_5731.as_str());
    }
    writer.finish();
    Ok(aws_smithy_http::body::SdkBody::from(out))
}

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