#[non_exhaustive]
pub enum OfferingClassType {
    Convertible,
    Standard,
    Unknown(UnknownVariantValue),
}
Expand description

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

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

Convertible

§

Standard

§

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 84043)
84042
84043
84044
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/operation_ser.rs (line 11589)
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
pub fn serialize_operation_crate_operation_describe_reserved_instances(
    input: &crate::input::DescribeReservedInstancesInput,
) -> 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, "DescribeReservedInstances", "2016-11-15");
    #[allow(unused_mut)]
    let mut scope_3287 = writer.prefix("Filter");
    if let Some(var_3288) = &input.filters {
        let mut list_3290 = scope_3287.start_list(true, Some("Filter"));
        for item_3289 in var_3288 {
            #[allow(unused_mut)]
            let mut entry_3291 = list_3290.entry();
            crate::query_ser::serialize_structure_crate_model_filter(entry_3291, item_3289)?;
        }
        list_3290.finish();
    }
    #[allow(unused_mut)]
    let mut scope_3292 = writer.prefix("OfferingClass");
    if let Some(var_3293) = &input.offering_class {
        scope_3292.string(var_3293.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_3294 = writer.prefix("ReservedInstancesId");
    if let Some(var_3295) = &input.reserved_instances_ids {
        let mut list_3297 = scope_3294.start_list(true, Some("ReservedInstancesId"));
        for item_3296 in var_3295 {
            #[allow(unused_mut)]
            let mut entry_3298 = list_3297.entry();
            entry_3298.string(item_3296);
        }
        list_3297.finish();
    }
    #[allow(unused_mut)]
    let mut scope_3299 = writer.prefix("DryRun");
    if let Some(var_3300) = &input.dry_run {
        scope_3299.boolean(*var_3300);
    }
    #[allow(unused_mut)]
    let mut scope_3301 = writer.prefix("OfferingType");
    if let Some(var_3302) = &input.offering_type {
        scope_3301.string(var_3302.as_str());
    }
    writer.finish();
    Ok(aws_smithy_http::body::SdkBody::from(out))
}

pub fn serialize_operation_crate_operation_describe_reserved_instances_listings(
    input: &crate::input::DescribeReservedInstancesListingsInput,
) -> 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,
        "DescribeReservedInstancesListings",
        "2016-11-15",
    );
    #[allow(unused_mut)]
    let mut scope_3303 = writer.prefix("Filter");
    if let Some(var_3304) = &input.filters {
        let mut list_3306 = scope_3303.start_list(true, Some("Filter"));
        for item_3305 in var_3304 {
            #[allow(unused_mut)]
            let mut entry_3307 = list_3306.entry();
            crate::query_ser::serialize_structure_crate_model_filter(entry_3307, item_3305)?;
        }
        list_3306.finish();
    }
    #[allow(unused_mut)]
    let mut scope_3308 = writer.prefix("ReservedInstancesId");
    if let Some(var_3309) = &input.reserved_instances_id {
        scope_3308.string(var_3309);
    }
    #[allow(unused_mut)]
    let mut scope_3310 = writer.prefix("ReservedInstancesListingId");
    if let Some(var_3311) = &input.reserved_instances_listing_id {
        scope_3310.string(var_3311);
    }
    writer.finish();
    Ok(aws_smithy_http::body::SdkBody::from(out))
}

pub fn serialize_operation_crate_operation_describe_reserved_instances_modifications(
    input: &crate::input::DescribeReservedInstancesModificationsInput,
) -> 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,
        "DescribeReservedInstancesModifications",
        "2016-11-15",
    );
    #[allow(unused_mut)]
    let mut scope_3312 = writer.prefix("Filter");
    if let Some(var_3313) = &input.filters {
        let mut list_3315 = scope_3312.start_list(true, Some("Filter"));
        for item_3314 in var_3313 {
            #[allow(unused_mut)]
            let mut entry_3316 = list_3315.entry();
            crate::query_ser::serialize_structure_crate_model_filter(entry_3316, item_3314)?;
        }
        list_3315.finish();
    }
    #[allow(unused_mut)]
    let mut scope_3317 = writer.prefix("ReservedInstancesModificationId");
    if let Some(var_3318) = &input.reserved_instances_modification_ids {
        let mut list_3320 = scope_3317.start_list(true, Some("ReservedInstancesModificationId"));
        for item_3319 in var_3318 {
            #[allow(unused_mut)]
            let mut entry_3321 = list_3320.entry();
            entry_3321.string(item_3319);
        }
        list_3320.finish();
    }
    #[allow(unused_mut)]
    let mut scope_3322 = writer.prefix("NextToken");
    if let Some(var_3323) = &input.next_token {
        scope_3322.string(var_3323);
    }
    writer.finish();
    Ok(aws_smithy_http::body::SdkBody::from(out))
}

pub fn serialize_operation_crate_operation_describe_reserved_instances_offerings(
    input: &crate::input::DescribeReservedInstancesOfferingsInput,
) -> 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,
        "DescribeReservedInstancesOfferings",
        "2016-11-15",
    );
    #[allow(unused_mut)]
    let mut scope_3324 = writer.prefix("AvailabilityZone");
    if let Some(var_3325) = &input.availability_zone {
        scope_3324.string(var_3325);
    }
    #[allow(unused_mut)]
    let mut scope_3326 = writer.prefix("Filter");
    if let Some(var_3327) = &input.filters {
        let mut list_3329 = scope_3326.start_list(true, Some("Filter"));
        for item_3328 in var_3327 {
            #[allow(unused_mut)]
            let mut entry_3330 = list_3329.entry();
            crate::query_ser::serialize_structure_crate_model_filter(entry_3330, item_3328)?;
        }
        list_3329.finish();
    }
    #[allow(unused_mut)]
    let mut scope_3331 = writer.prefix("IncludeMarketplace");
    if let Some(var_3332) = &input.include_marketplace {
        scope_3331.boolean(*var_3332);
    }
    #[allow(unused_mut)]
    let mut scope_3333 = writer.prefix("InstanceType");
    if let Some(var_3334) = &input.instance_type {
        scope_3333.string(var_3334.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_3335 = writer.prefix("MaxDuration");
    if let Some(var_3336) = &input.max_duration {
        scope_3335.number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_3336).into()),
        );
    }
    #[allow(unused_mut)]
    let mut scope_3337 = writer.prefix("MaxInstanceCount");
    if let Some(var_3338) = &input.max_instance_count {
        scope_3337.number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_3338).into()),
        );
    }
    #[allow(unused_mut)]
    let mut scope_3339 = writer.prefix("MinDuration");
    if let Some(var_3340) = &input.min_duration {
        scope_3339.number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_3340).into()),
        );
    }
    #[allow(unused_mut)]
    let mut scope_3341 = writer.prefix("OfferingClass");
    if let Some(var_3342) = &input.offering_class {
        scope_3341.string(var_3342.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_3343 = writer.prefix("ProductDescription");
    if let Some(var_3344) = &input.product_description {
        scope_3343.string(var_3344.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_3345 = writer.prefix("ReservedInstancesOfferingId");
    if let Some(var_3346) = &input.reserved_instances_offering_ids {
        let mut list_3348 = scope_3345.start_list(true, None);
        for item_3347 in var_3346 {
            #[allow(unused_mut)]
            let mut entry_3349 = list_3348.entry();
            entry_3349.string(item_3347);
        }
        list_3348.finish();
    }
    #[allow(unused_mut)]
    let mut scope_3350 = writer.prefix("DryRun");
    if let Some(var_3351) = &input.dry_run {
        scope_3350.boolean(*var_3351);
    }
    #[allow(unused_mut)]
    let mut scope_3352 = writer.prefix("InstanceTenancy");
    if let Some(var_3353) = &input.instance_tenancy {
        scope_3352.string(var_3353.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_3354 = writer.prefix("MaxResults");
    if let Some(var_3355) = &input.max_results {
        scope_3354.number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_3355).into()),
        );
    }
    #[allow(unused_mut)]
    let mut scope_3356 = writer.prefix("NextToken");
    if let Some(var_3357) = &input.next_token {
        scope_3356.string(var_3357);
    }
    #[allow(unused_mut)]
    let mut scope_3358 = writer.prefix("OfferingType");
    if let Some(var_3359) = &input.offering_type {
        scope_3358.string(var_3359.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