Enum aws_sdk_ec2::model::AllocationStrategy
source · #[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
CapacityOptimized
CapacityOptimizedPrioritized
Diversified
LowestPrice
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl AllocationStrategy
impl AllocationStrategy
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the &str
value of the enum member.
Examples found in repository?
More examples
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(())
}
Trait Implementations§
source§impl AsRef<str> for AllocationStrategy
impl AsRef<str> for AllocationStrategy
source§impl Clone for AllocationStrategy
impl Clone for AllocationStrategy
source§fn clone(&self) -> AllocationStrategy
fn clone(&self) -> AllocationStrategy
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for AllocationStrategy
impl Debug for AllocationStrategy
source§impl From<&str> for AllocationStrategy
impl From<&str> for AllocationStrategy
source§impl FromStr for AllocationStrategy
impl FromStr for AllocationStrategy
source§impl Hash for AllocationStrategy
impl Hash for AllocationStrategy
source§impl Ord for AllocationStrategy
impl Ord for AllocationStrategy
source§fn cmp(&self, other: &AllocationStrategy) -> Ordering
fn cmp(&self, other: &AllocationStrategy) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<AllocationStrategy> for AllocationStrategy
impl PartialEq<AllocationStrategy> for AllocationStrategy
source§fn eq(&self, other: &AllocationStrategy) -> bool
fn eq(&self, other: &AllocationStrategy) -> bool
source§impl PartialOrd<AllocationStrategy> for AllocationStrategy
impl PartialOrd<AllocationStrategy> for AllocationStrategy
source§fn partial_cmp(&self, other: &AllocationStrategy) -> Option<Ordering>
fn partial_cmp(&self, other: &AllocationStrategy) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Eq for AllocationStrategy
impl StructuralEq for AllocationStrategy
impl StructuralPartialEq for AllocationStrategy
Auto Trait Implementations§
impl RefUnwindSafe for AllocationStrategy
impl Send for AllocationStrategy
impl Sync for AllocationStrategy
impl Unpin for AllocationStrategy
impl UnwindSafe for AllocationStrategy
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.