Enum aws_sdk_ec2::model::OfferingTypeValues
source · #[non_exhaustive]
pub enum OfferingTypeValues {
AllUpfront,
HeavyUtilization,
LightUtilization,
MediumUtilization,
NoUpfront,
PartialUpfront,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against OfferingTypeValues
, 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 offeringtypevalues = unimplemented!();
match offeringtypevalues {
OfferingTypeValues::AllUpfront => { /* ... */ },
OfferingTypeValues::HeavyUtilization => { /* ... */ },
OfferingTypeValues::LightUtilization => { /* ... */ },
OfferingTypeValues::MediumUtilization => { /* ... */ },
OfferingTypeValues::NoUpfront => { /* ... */ },
OfferingTypeValues::PartialUpfront => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when offeringtypevalues
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant OfferingTypeValues::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
OfferingTypeValues::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 OfferingTypeValues::NewFeature
is defined.
Specifically, when offeringtypevalues
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on OfferingTypeValues::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
AllUpfront
HeavyUtilization
LightUtilization
MediumUtilization
NoUpfront
PartialUpfront
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl OfferingTypeValues
impl OfferingTypeValues
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
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))
}
Trait Implementations§
source§impl AsRef<str> for OfferingTypeValues
impl AsRef<str> for OfferingTypeValues
source§impl Clone for OfferingTypeValues
impl Clone for OfferingTypeValues
source§fn clone(&self) -> OfferingTypeValues
fn clone(&self) -> OfferingTypeValues
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for OfferingTypeValues
impl Debug for OfferingTypeValues
source§impl From<&str> for OfferingTypeValues
impl From<&str> for OfferingTypeValues
source§impl FromStr for OfferingTypeValues
impl FromStr for OfferingTypeValues
source§impl Hash for OfferingTypeValues
impl Hash for OfferingTypeValues
source§impl Ord for OfferingTypeValues
impl Ord for OfferingTypeValues
source§fn cmp(&self, other: &OfferingTypeValues) -> Ordering
fn cmp(&self, other: &OfferingTypeValues) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<OfferingTypeValues> for OfferingTypeValues
impl PartialEq<OfferingTypeValues> for OfferingTypeValues
source§fn eq(&self, other: &OfferingTypeValues) -> bool
fn eq(&self, other: &OfferingTypeValues) -> bool
source§impl PartialOrd<OfferingTypeValues> for OfferingTypeValues
impl PartialOrd<OfferingTypeValues> for OfferingTypeValues
source§fn partial_cmp(&self, other: &OfferingTypeValues) -> Option<Ordering>
fn partial_cmp(&self, other: &OfferingTypeValues) -> 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 OfferingTypeValues
impl StructuralEq for OfferingTypeValues
impl StructuralPartialEq for OfferingTypeValues
Auto Trait Implementations§
impl RefUnwindSafe for OfferingTypeValues
impl Send for OfferingTypeValues
impl Sync for OfferingTypeValues
impl Unpin for OfferingTypeValues
impl UnwindSafe for OfferingTypeValues
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.