Enum aws_sdk_ec2::model::LocationType
source · #[non_exhaustive]
pub enum LocationType {
AvailabilityZone,
AvailabilityZoneId,
Region,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against LocationType
, 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 locationtype = unimplemented!();
match locationtype {
LocationType::AvailabilityZone => { /* ... */ },
LocationType::AvailabilityZoneId => { /* ... */ },
LocationType::Region => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when locationtype
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant LocationType::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
LocationType::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 LocationType::NewFeature
is defined.
Specifically, when locationtype
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on LocationType::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
AvailabilityZone
AvailabilityZoneId
Region
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl LocationType
impl LocationType
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
9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892
pub fn serialize_operation_crate_operation_describe_instance_type_offerings(
input: &crate::input::DescribeInstanceTypeOfferingsInput,
) -> 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, "DescribeInstanceTypeOfferings", "2016-11-15");
#[allow(unused_mut)]
let mut scope_2754 = writer.prefix("DryRun");
if let Some(var_2755) = &input.dry_run {
scope_2754.boolean(*var_2755);
}
#[allow(unused_mut)]
let mut scope_2756 = writer.prefix("LocationType");
if let Some(var_2757) = &input.location_type {
scope_2756.string(var_2757.as_str());
}
#[allow(unused_mut)]
let mut scope_2758 = writer.prefix("Filter");
if let Some(var_2759) = &input.filters {
let mut list_2761 = scope_2758.start_list(true, Some("Filter"));
for item_2760 in var_2759 {
#[allow(unused_mut)]
let mut entry_2762 = list_2761.entry();
crate::query_ser::serialize_structure_crate_model_filter(entry_2762, item_2760)?;
}
list_2761.finish();
}
#[allow(unused_mut)]
let mut scope_2763 = writer.prefix("MaxResults");
if let Some(var_2764) = &input.max_results {
scope_2763.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_2764).into()),
);
}
#[allow(unused_mut)]
let mut scope_2765 = writer.prefix("NextToken");
if let Some(var_2766) = &input.next_token {
scope_2765.string(var_2766);
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}
Trait Implementations§
source§impl AsRef<str> for LocationType
impl AsRef<str> for LocationType
source§impl Clone for LocationType
impl Clone for LocationType
source§fn clone(&self) -> LocationType
fn clone(&self) -> LocationType
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for LocationType
impl Debug for LocationType
source§impl From<&str> for LocationType
impl From<&str> for LocationType
source§impl FromStr for LocationType
impl FromStr for LocationType
source§impl Hash for LocationType
impl Hash for LocationType
source§impl Ord for LocationType
impl Ord for LocationType
source§fn cmp(&self, other: &LocationType) -> Ordering
fn cmp(&self, other: &LocationType) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<LocationType> for LocationType
impl PartialEq<LocationType> for LocationType
source§fn eq(&self, other: &LocationType) -> bool
fn eq(&self, other: &LocationType) -> bool
source§impl PartialOrd<LocationType> for LocationType
impl PartialOrd<LocationType> for LocationType
source§fn partial_cmp(&self, other: &LocationType) -> Option<Ordering>
fn partial_cmp(&self, other: &LocationType) -> 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 LocationType
impl StructuralEq for LocationType
impl StructuralPartialEq for LocationType
Auto Trait Implementations§
impl RefUnwindSafe for LocationType
impl Send for LocationType
impl Sync for LocationType
impl Unpin for LocationType
impl UnwindSafe for LocationType
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.