#[non_exhaustive]
pub enum NetworkInterfaceCreationType {
Branch,
Efa,
Trunk,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against NetworkInterfaceCreationType
, 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 networkinterfacecreationtype = unimplemented!();
match networkinterfacecreationtype {
NetworkInterfaceCreationType::Branch => { /* ... */ },
NetworkInterfaceCreationType::Efa => { /* ... */ },
NetworkInterfaceCreationType::Trunk => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when networkinterfacecreationtype
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant NetworkInterfaceCreationType::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
NetworkInterfaceCreationType::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 NetworkInterfaceCreationType::NewFeature
is defined.
Specifically, when networkinterfacecreationtype
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on NetworkInterfaceCreationType::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
Branch
Efa
Trunk
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl NetworkInterfaceCreationType
impl NetworkInterfaceCreationType
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
3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858
pub fn serialize_operation_crate_operation_create_network_interface(
input: &crate::input::CreateNetworkInterfaceInput,
) -> 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, "CreateNetworkInterface", "2016-11-15");
#[allow(unused_mut)]
let mut scope_1073 = writer.prefix("Description");
if let Some(var_1074) = &input.description {
scope_1073.string(var_1074);
}
#[allow(unused_mut)]
let mut scope_1075 = writer.prefix("DryRun");
if let Some(var_1076) = &input.dry_run {
scope_1075.boolean(*var_1076);
}
#[allow(unused_mut)]
let mut scope_1077 = writer.prefix("SecurityGroupId");
if let Some(var_1078) = &input.groups {
let mut list_1080 = scope_1077.start_list(true, Some("SecurityGroupId"));
for item_1079 in var_1078 {
#[allow(unused_mut)]
let mut entry_1081 = list_1080.entry();
entry_1081.string(item_1079);
}
list_1080.finish();
}
#[allow(unused_mut)]
let mut scope_1082 = writer.prefix("Ipv6AddressCount");
if let Some(var_1083) = &input.ipv6_address_count {
scope_1082.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_1083).into()),
);
}
#[allow(unused_mut)]
let mut scope_1084 = writer.prefix("Ipv6Addresses");
if let Some(var_1085) = &input.ipv6_addresses {
let mut list_1087 = scope_1084.start_list(true, Some("item"));
for item_1086 in var_1085 {
#[allow(unused_mut)]
let mut entry_1088 = list_1087.entry();
crate::query_ser::serialize_structure_crate_model_instance_ipv6_address(
entry_1088, item_1086,
)?;
}
list_1087.finish();
}
#[allow(unused_mut)]
let mut scope_1089 = writer.prefix("PrivateIpAddress");
if let Some(var_1090) = &input.private_ip_address {
scope_1089.string(var_1090);
}
#[allow(unused_mut)]
let mut scope_1091 = writer.prefix("PrivateIpAddresses");
if let Some(var_1092) = &input.private_ip_addresses {
let mut list_1094 = scope_1091.start_list(true, Some("item"));
for item_1093 in var_1092 {
#[allow(unused_mut)]
let mut entry_1095 = list_1094.entry();
crate::query_ser::serialize_structure_crate_model_private_ip_address_specification(
entry_1095, item_1093,
)?;
}
list_1094.finish();
}
#[allow(unused_mut)]
let mut scope_1096 = writer.prefix("SecondaryPrivateIpAddressCount");
if let Some(var_1097) = &input.secondary_private_ip_address_count {
scope_1096.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_1097).into()),
);
}
#[allow(unused_mut)]
let mut scope_1098 = writer.prefix("Ipv4Prefix");
if let Some(var_1099) = &input.ipv4_prefixes {
let mut list_1101 = scope_1098.start_list(true, Some("item"));
for item_1100 in var_1099 {
#[allow(unused_mut)]
let mut entry_1102 = list_1101.entry();
crate::query_ser::serialize_structure_crate_model_ipv4_prefix_specification_request(
entry_1102, item_1100,
)?;
}
list_1101.finish();
}
#[allow(unused_mut)]
let mut scope_1103 = writer.prefix("Ipv4PrefixCount");
if let Some(var_1104) = &input.ipv4_prefix_count {
scope_1103.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_1104).into()),
);
}
#[allow(unused_mut)]
let mut scope_1105 = writer.prefix("Ipv6Prefix");
if let Some(var_1106) = &input.ipv6_prefixes {
let mut list_1108 = scope_1105.start_list(true, Some("item"));
for item_1107 in var_1106 {
#[allow(unused_mut)]
let mut entry_1109 = list_1108.entry();
crate::query_ser::serialize_structure_crate_model_ipv6_prefix_specification_request(
entry_1109, item_1107,
)?;
}
list_1108.finish();
}
#[allow(unused_mut)]
let mut scope_1110 = writer.prefix("Ipv6PrefixCount");
if let Some(var_1111) = &input.ipv6_prefix_count {
scope_1110.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_1111).into()),
);
}
#[allow(unused_mut)]
let mut scope_1112 = writer.prefix("InterfaceType");
if let Some(var_1113) = &input.interface_type {
scope_1112.string(var_1113.as_str());
}
#[allow(unused_mut)]
let mut scope_1114 = writer.prefix("SubnetId");
if let Some(var_1115) = &input.subnet_id {
scope_1114.string(var_1115);
}
#[allow(unused_mut)]
let mut scope_1116 = writer.prefix("TagSpecification");
if let Some(var_1117) = &input.tag_specifications {
let mut list_1119 = scope_1116.start_list(true, Some("item"));
for item_1118 in var_1117 {
#[allow(unused_mut)]
let mut entry_1120 = list_1119.entry();
crate::query_ser::serialize_structure_crate_model_tag_specification(
entry_1120, item_1118,
)?;
}
list_1119.finish();
}
#[allow(unused_mut)]
let mut scope_1121 = writer.prefix("ClientToken");
if let Some(var_1122) = &input.client_token {
scope_1121.string(var_1122);
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}
Trait Implementations§
source§impl AsRef<str> for NetworkInterfaceCreationType
impl AsRef<str> for NetworkInterfaceCreationType
source§impl Clone for NetworkInterfaceCreationType
impl Clone for NetworkInterfaceCreationType
source§fn clone(&self) -> NetworkInterfaceCreationType
fn clone(&self) -> NetworkInterfaceCreationType
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for NetworkInterfaceCreationType
impl Debug for NetworkInterfaceCreationType
source§impl From<&str> for NetworkInterfaceCreationType
impl From<&str> for NetworkInterfaceCreationType
source§impl Hash for NetworkInterfaceCreationType
impl Hash for NetworkInterfaceCreationType
source§impl Ord for NetworkInterfaceCreationType
impl Ord for NetworkInterfaceCreationType
source§fn cmp(&self, other: &NetworkInterfaceCreationType) -> Ordering
fn cmp(&self, other: &NetworkInterfaceCreationType) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<NetworkInterfaceCreationType> for NetworkInterfaceCreationType
impl PartialEq<NetworkInterfaceCreationType> for NetworkInterfaceCreationType
source§fn eq(&self, other: &NetworkInterfaceCreationType) -> bool
fn eq(&self, other: &NetworkInterfaceCreationType) -> bool
source§impl PartialOrd<NetworkInterfaceCreationType> for NetworkInterfaceCreationType
impl PartialOrd<NetworkInterfaceCreationType> for NetworkInterfaceCreationType
source§fn partial_cmp(&self, other: &NetworkInterfaceCreationType) -> Option<Ordering>
fn partial_cmp(&self, other: &NetworkInterfaceCreationType) -> 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 NetworkInterfaceCreationType
impl StructuralEq for NetworkInterfaceCreationType
impl StructuralPartialEq for NetworkInterfaceCreationType
Auto Trait Implementations§
impl RefUnwindSafe for NetworkInterfaceCreationType
impl Send for NetworkInterfaceCreationType
impl Sync for NetworkInterfaceCreationType
impl Unpin for NetworkInterfaceCreationType
impl UnwindSafe for NetworkInterfaceCreationType
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.