#[non_exhaustive]
pub enum AllocationStrategy {
    CapacityOptimized,
    CapacityOptimizedPrioritized,
    Diversified,
    LowestPrice,
    Unknown(UnknownVariantValue),
}
Expand description

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

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

CapacityOptimized

§

CapacityOptimizedPrioritized

§

Diversified

§

LowestPrice

§

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 29603)
29602
29603
29604
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/query_ser.rs (line 2879)
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
pub fn serialize_structure_crate_model_spot_fleet_request_config_data(
    mut writer: aws_smithy_query::QueryValueWriter,
    input: &crate::model::SpotFleetRequestConfigData,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    #[allow(unused_mut)]
    let mut scope_815 = writer.prefix("AllocationStrategy");
    if let Some(var_816) = &input.allocation_strategy {
        scope_815.string(var_816.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_817 = writer.prefix("OnDemandAllocationStrategy");
    if let Some(var_818) = &input.on_demand_allocation_strategy {
        scope_817.string(var_818.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_819 = writer.prefix("SpotMaintenanceStrategies");
    if let Some(var_820) = &input.spot_maintenance_strategies {
        crate::query_ser::serialize_structure_crate_model_spot_maintenance_strategies(
            scope_819, var_820,
        )?;
    }
    #[allow(unused_mut)]
    let mut scope_821 = writer.prefix("ClientToken");
    if let Some(var_822) = &input.client_token {
        scope_821.string(var_822);
    }
    #[allow(unused_mut)]
    let mut scope_823 = writer.prefix("ExcessCapacityTerminationPolicy");
    if let Some(var_824) = &input.excess_capacity_termination_policy {
        scope_823.string(var_824.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_825 = writer.prefix("FulfilledCapacity");
    if let Some(var_826) = &input.fulfilled_capacity {
        scope_825.number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::Float((*var_826).into()),
        );
    }
    #[allow(unused_mut)]
    let mut scope_827 = writer.prefix("OnDemandFulfilledCapacity");
    if let Some(var_828) = &input.on_demand_fulfilled_capacity {
        scope_827.number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::Float((*var_828).into()),
        );
    }
    #[allow(unused_mut)]
    let mut scope_829 = writer.prefix("IamFleetRole");
    if let Some(var_830) = &input.iam_fleet_role {
        scope_829.string(var_830);
    }
    #[allow(unused_mut)]
    let mut scope_831 = writer.prefix("LaunchSpecifications");
    if let Some(var_832) = &input.launch_specifications {
        let mut list_834 = scope_831.start_list(true, Some("item"));
        for item_833 in var_832 {
            #[allow(unused_mut)]
            let mut entry_835 = list_834.entry();
            crate::query_ser::serialize_structure_crate_model_spot_fleet_launch_specification(
                entry_835, item_833,
            )?;
        }
        list_834.finish();
    }
    #[allow(unused_mut)]
    let mut scope_836 = writer.prefix("LaunchTemplateConfigs");
    if let Some(var_837) = &input.launch_template_configs {
        let mut list_839 = scope_836.start_list(true, Some("item"));
        for item_838 in var_837 {
            #[allow(unused_mut)]
            let mut entry_840 = list_839.entry();
            crate::query_ser::serialize_structure_crate_model_launch_template_config(
                entry_840, item_838,
            )?;
        }
        list_839.finish();
    }
    #[allow(unused_mut)]
    let mut scope_841 = writer.prefix("SpotPrice");
    if let Some(var_842) = &input.spot_price {
        scope_841.string(var_842);
    }
    #[allow(unused_mut)]
    let mut scope_843 = writer.prefix("TargetCapacity");
    if let Some(var_844) = &input.target_capacity {
        scope_843.number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_844).into()),
        );
    }
    #[allow(unused_mut)]
    let mut scope_845 = writer.prefix("OnDemandTargetCapacity");
    if let Some(var_846) = &input.on_demand_target_capacity {
        scope_845.number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_846).into()),
        );
    }
    #[allow(unused_mut)]
    let mut scope_847 = writer.prefix("OnDemandMaxTotalPrice");
    if let Some(var_848) = &input.on_demand_max_total_price {
        scope_847.string(var_848);
    }
    #[allow(unused_mut)]
    let mut scope_849 = writer.prefix("SpotMaxTotalPrice");
    if let Some(var_850) = &input.spot_max_total_price {
        scope_849.string(var_850);
    }
    #[allow(unused_mut)]
    let mut scope_851 = writer.prefix("TerminateInstancesWithExpiration");
    if let Some(var_852) = &input.terminate_instances_with_expiration {
        scope_851.boolean(*var_852);
    }
    #[allow(unused_mut)]
    let mut scope_853 = writer.prefix("Type");
    if let Some(var_854) = &input.r#type {
        scope_853.string(var_854.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_855 = writer.prefix("ValidFrom");
    if let Some(var_856) = &input.valid_from {
        scope_855.date_time(var_856, aws_smithy_types::date_time::Format::DateTime)?;
    }
    #[allow(unused_mut)]
    let mut scope_857 = writer.prefix("ValidUntil");
    if let Some(var_858) = &input.valid_until {
        scope_857.date_time(var_858, aws_smithy_types::date_time::Format::DateTime)?;
    }
    #[allow(unused_mut)]
    let mut scope_859 = writer.prefix("ReplaceUnhealthyInstances");
    if let Some(var_860) = &input.replace_unhealthy_instances {
        scope_859.boolean(*var_860);
    }
    #[allow(unused_mut)]
    let mut scope_861 = writer.prefix("InstanceInterruptionBehavior");
    if let Some(var_862) = &input.instance_interruption_behavior {
        scope_861.string(var_862.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_863 = writer.prefix("LoadBalancersConfig");
    if let Some(var_864) = &input.load_balancers_config {
        crate::query_ser::serialize_structure_crate_model_load_balancers_config(
            scope_863, var_864,
        )?;
    }
    #[allow(unused_mut)]
    let mut scope_865 = writer.prefix("InstancePoolsToUseCount");
    if let Some(var_866) = &input.instance_pools_to_use_count {
        scope_865.number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_866).into()),
        );
    }
    #[allow(unused_mut)]
    let mut scope_867 = writer.prefix("Context");
    if let Some(var_868) = &input.context {
        scope_867.string(var_868);
    }
    #[allow(unused_mut)]
    let mut scope_869 = writer.prefix("TargetCapacityUnitType");
    if let Some(var_870) = &input.target_capacity_unit_type {
        scope_869.string(var_870.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_871 = writer.prefix("TagSpecification");
    if let Some(var_872) = &input.tag_specifications {
        let mut list_874 = scope_871.start_list(true, Some("item"));
        for item_873 in var_872 {
            #[allow(unused_mut)]
            let mut entry_875 = list_874.entry();
            crate::query_ser::serialize_structure_crate_model_tag_specification(
                entry_875, item_873,
            )?;
        }
        list_874.finish();
    }
    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