#[non_exhaustive]
pub enum TpmSupportValues {
    V20,
    Unknown(UnknownVariantValue),
}
Expand description

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

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

V20

§

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 32814)
32813
32814
32815
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/operation_ser.rs (line 20293)
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