Enum aws_sdk_ec2::model::FleetType
source · #[non_exhaustive]
pub enum FleetType {
Instant,
Maintain,
Request,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against FleetType
, 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 fleettype = unimplemented!();
match fleettype {
FleetType::Instant => { /* ... */ },
FleetType::Maintain => { /* ... */ },
FleetType::Request => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when fleettype
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant FleetType::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
FleetType::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 FleetType::NewFeature
is defined.
Specifically, when fleettype
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on FleetType::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
Instant
Maintain
Request
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl FleetType
impl FleetType
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
2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526
pub fn serialize_operation_crate_operation_create_fleet(
input: &crate::input::CreateFleetInput,
) -> 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, "CreateFleet", "2016-11-15");
#[allow(unused_mut)]
let mut scope_678 = writer.prefix("DryRun");
if let Some(var_679) = &input.dry_run {
scope_678.boolean(*var_679);
}
#[allow(unused_mut)]
let mut scope_680 = writer.prefix("ClientToken");
if let Some(var_681) = &input.client_token {
scope_680.string(var_681);
}
#[allow(unused_mut)]
let mut scope_682 = writer.prefix("SpotOptions");
if let Some(var_683) = &input.spot_options {
crate::query_ser::serialize_structure_crate_model_spot_options_request(scope_682, var_683)?;
}
#[allow(unused_mut)]
let mut scope_684 = writer.prefix("OnDemandOptions");
if let Some(var_685) = &input.on_demand_options {
crate::query_ser::serialize_structure_crate_model_on_demand_options_request(
scope_684, var_685,
)?;
}
#[allow(unused_mut)]
let mut scope_686 = writer.prefix("ExcessCapacityTerminationPolicy");
if let Some(var_687) = &input.excess_capacity_termination_policy {
scope_686.string(var_687.as_str());
}
#[allow(unused_mut)]
let mut scope_688 = writer.prefix("LaunchTemplateConfigs");
if let Some(var_689) = &input.launch_template_configs {
let mut list_691 = scope_688.start_list(true, Some("item"));
for item_690 in var_689 {
#[allow(unused_mut)]
let mut entry_692 = list_691.entry();
crate::query_ser::serialize_structure_crate_model_fleet_launch_template_config_request(
entry_692, item_690,
)?;
}
list_691.finish();
}
#[allow(unused_mut)]
let mut scope_693 = writer.prefix("TargetCapacitySpecification");
if let Some(var_694) = &input.target_capacity_specification {
crate::query_ser::serialize_structure_crate_model_target_capacity_specification_request(
scope_693, var_694,
)?;
}
#[allow(unused_mut)]
let mut scope_695 = writer.prefix("TerminateInstancesWithExpiration");
if let Some(var_696) = &input.terminate_instances_with_expiration {
scope_695.boolean(*var_696);
}
#[allow(unused_mut)]
let mut scope_697 = writer.prefix("Type");
if let Some(var_698) = &input.r#type {
scope_697.string(var_698.as_str());
}
#[allow(unused_mut)]
let mut scope_699 = writer.prefix("ValidFrom");
if let Some(var_700) = &input.valid_from {
scope_699.date_time(var_700, aws_smithy_types::date_time::Format::DateTime)?;
}
#[allow(unused_mut)]
let mut scope_701 = writer.prefix("ValidUntil");
if let Some(var_702) = &input.valid_until {
scope_701.date_time(var_702, aws_smithy_types::date_time::Format::DateTime)?;
}
#[allow(unused_mut)]
let mut scope_703 = writer.prefix("ReplaceUnhealthyInstances");
if let Some(var_704) = &input.replace_unhealthy_instances {
scope_703.boolean(*var_704);
}
#[allow(unused_mut)]
let mut scope_705 = writer.prefix("TagSpecification");
if let Some(var_706) = &input.tag_specifications {
let mut list_708 = scope_705.start_list(true, Some("item"));
for item_707 in var_706 {
#[allow(unused_mut)]
let mut entry_709 = list_708.entry();
crate::query_ser::serialize_structure_crate_model_tag_specification(
entry_709, item_707,
)?;
}
list_708.finish();
}
#[allow(unused_mut)]
let mut scope_710 = writer.prefix("Context");
if let Some(var_711) = &input.context {
scope_710.string(var_711);
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}
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 Ord for FleetType
impl Ord for FleetType
source§impl PartialOrd<FleetType> for FleetType
impl PartialOrd<FleetType> for FleetType
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 FleetType
impl StructuralEq for FleetType
impl StructuralPartialEq for FleetType
Auto Trait Implementations§
impl RefUnwindSafe for FleetType
impl Send for FleetType
impl Sync for FleetType
impl Unpin for FleetType
impl UnwindSafe for FleetType
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.