Enum aws_sdk_ec2::model::IpamPoolAwsService
source · #[non_exhaustive]
pub enum IpamPoolAwsService {
Ec2,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against IpamPoolAwsService
, 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 ipampoolawsservice = unimplemented!();
match ipampoolawsservice {
IpamPoolAwsService::Ec2 => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when ipampoolawsservice
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant IpamPoolAwsService::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
IpamPoolAwsService::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 IpamPoolAwsService::NewFeature
is defined.
Specifically, when ipampoolawsservice
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on IpamPoolAwsService::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
Ec2
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl IpamPoolAwsService
impl IpamPoolAwsService
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
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
pub fn serialize_operation_crate_operation_create_ipam_pool(
input: &crate::input::CreateIpamPoolInput,
) -> 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, "CreateIpamPool", "2016-11-15");
#[allow(unused_mut)]
let mut scope_835 = writer.prefix("DryRun");
if let Some(var_836) = &input.dry_run {
scope_835.boolean(*var_836);
}
#[allow(unused_mut)]
let mut scope_837 = writer.prefix("IpamScopeId");
if let Some(var_838) = &input.ipam_scope_id {
scope_837.string(var_838);
}
#[allow(unused_mut)]
let mut scope_839 = writer.prefix("Locale");
if let Some(var_840) = &input.locale {
scope_839.string(var_840);
}
#[allow(unused_mut)]
let mut scope_841 = writer.prefix("SourceIpamPoolId");
if let Some(var_842) = &input.source_ipam_pool_id {
scope_841.string(var_842);
}
#[allow(unused_mut)]
let mut scope_843 = writer.prefix("Description");
if let Some(var_844) = &input.description {
scope_843.string(var_844);
}
#[allow(unused_mut)]
let mut scope_845 = writer.prefix("AddressFamily");
if let Some(var_846) = &input.address_family {
scope_845.string(var_846.as_str());
}
#[allow(unused_mut)]
let mut scope_847 = writer.prefix("AutoImport");
if let Some(var_848) = &input.auto_import {
scope_847.boolean(*var_848);
}
#[allow(unused_mut)]
let mut scope_849 = writer.prefix("PubliclyAdvertisable");
if let Some(var_850) = &input.publicly_advertisable {
scope_849.boolean(*var_850);
}
#[allow(unused_mut)]
let mut scope_851 = writer.prefix("AllocationMinNetmaskLength");
if let Some(var_852) = &input.allocation_min_netmask_length {
scope_851.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_852).into()),
);
}
#[allow(unused_mut)]
let mut scope_853 = writer.prefix("AllocationMaxNetmaskLength");
if let Some(var_854) = &input.allocation_max_netmask_length {
scope_853.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_854).into()),
);
}
#[allow(unused_mut)]
let mut scope_855 = writer.prefix("AllocationDefaultNetmaskLength");
if let Some(var_856) = &input.allocation_default_netmask_length {
scope_855.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_856).into()),
);
}
#[allow(unused_mut)]
let mut scope_857 = writer.prefix("AllocationResourceTag");
if let Some(var_858) = &input.allocation_resource_tags {
let mut list_860 = scope_857.start_list(true, Some("item"));
for item_859 in var_858 {
#[allow(unused_mut)]
let mut entry_861 = list_860.entry();
crate::query_ser::serialize_structure_crate_model_request_ipam_resource_tag(
entry_861, item_859,
)?;
}
list_860.finish();
}
#[allow(unused_mut)]
let mut scope_862 = writer.prefix("TagSpecification");
if let Some(var_863) = &input.tag_specifications {
let mut list_865 = scope_862.start_list(true, Some("item"));
for item_864 in var_863 {
#[allow(unused_mut)]
let mut entry_866 = list_865.entry();
crate::query_ser::serialize_structure_crate_model_tag_specification(
entry_866, item_864,
)?;
}
list_865.finish();
}
#[allow(unused_mut)]
let mut scope_867 = writer.prefix("ClientToken");
if let Some(var_868) = &input.client_token {
scope_867.string(var_868);
}
#[allow(unused_mut)]
let mut scope_869 = writer.prefix("AwsService");
if let Some(var_870) = &input.aws_service {
scope_869.string(var_870.as_str());
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}
Trait Implementations§
source§impl AsRef<str> for IpamPoolAwsService
impl AsRef<str> for IpamPoolAwsService
source§impl Clone for IpamPoolAwsService
impl Clone for IpamPoolAwsService
source§fn clone(&self) -> IpamPoolAwsService
fn clone(&self) -> IpamPoolAwsService
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for IpamPoolAwsService
impl Debug for IpamPoolAwsService
source§impl From<&str> for IpamPoolAwsService
impl From<&str> for IpamPoolAwsService
source§impl FromStr for IpamPoolAwsService
impl FromStr for IpamPoolAwsService
source§impl Hash for IpamPoolAwsService
impl Hash for IpamPoolAwsService
source§impl Ord for IpamPoolAwsService
impl Ord for IpamPoolAwsService
source§fn cmp(&self, other: &IpamPoolAwsService) -> Ordering
fn cmp(&self, other: &IpamPoolAwsService) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<IpamPoolAwsService> for IpamPoolAwsService
impl PartialEq<IpamPoolAwsService> for IpamPoolAwsService
source§fn eq(&self, other: &IpamPoolAwsService) -> bool
fn eq(&self, other: &IpamPoolAwsService) -> bool
source§impl PartialOrd<IpamPoolAwsService> for IpamPoolAwsService
impl PartialOrd<IpamPoolAwsService> for IpamPoolAwsService
source§fn partial_cmp(&self, other: &IpamPoolAwsService) -> Option<Ordering>
fn partial_cmp(&self, other: &IpamPoolAwsService) -> 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 IpamPoolAwsService
impl StructuralEq for IpamPoolAwsService
impl StructuralPartialEq for IpamPoolAwsService
Auto Trait Implementations§
impl RefUnwindSafe for IpamPoolAwsService
impl Send for IpamPoolAwsService
impl Sync for IpamPoolAwsService
impl Unpin for IpamPoolAwsService
impl UnwindSafe for IpamPoolAwsService
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.