Enum aws_sdk_ec2::model::TransportProtocol
source · #[non_exhaustive]
pub enum TransportProtocol {
Tcp,
Udp,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against TransportProtocol
, 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 transportprotocol = unimplemented!();
match transportprotocol {
TransportProtocol::Tcp => { /* ... */ },
TransportProtocol::Udp => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when transportprotocol
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant TransportProtocol::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
TransportProtocol::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 TransportProtocol::NewFeature
is defined.
Specifically, when transportprotocol
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on TransportProtocol::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
Tcp
Udp
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl TransportProtocol
impl TransportProtocol
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
2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140
pub fn serialize_operation_crate_operation_create_client_vpn_endpoint(
input: &crate::input::CreateClientVpnEndpointInput,
) -> 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, "CreateClientVpnEndpoint", "2016-11-15");
#[allow(unused_mut)]
let mut scope_553 = writer.prefix("ClientCidrBlock");
if let Some(var_554) = &input.client_cidr_block {
scope_553.string(var_554);
}
#[allow(unused_mut)]
let mut scope_555 = writer.prefix("ServerCertificateArn");
if let Some(var_556) = &input.server_certificate_arn {
scope_555.string(var_556);
}
#[allow(unused_mut)]
let mut scope_557 = writer.prefix("Authentication");
if let Some(var_558) = &input.authentication_options {
let mut list_560 = scope_557.start_list(true, None);
for item_559 in var_558 {
#[allow(unused_mut)]
let mut entry_561 = list_560.entry();
crate::query_ser::serialize_structure_crate_model_client_vpn_authentication_request(
entry_561, item_559,
)?;
}
list_560.finish();
}
#[allow(unused_mut)]
let mut scope_562 = writer.prefix("ConnectionLogOptions");
if let Some(var_563) = &input.connection_log_options {
crate::query_ser::serialize_structure_crate_model_connection_log_options(
scope_562, var_563,
)?;
}
#[allow(unused_mut)]
let mut scope_564 = writer.prefix("DnsServers");
if let Some(var_565) = &input.dns_servers {
let mut list_567 = scope_564.start_list(true, Some("item"));
for item_566 in var_565 {
#[allow(unused_mut)]
let mut entry_568 = list_567.entry();
entry_568.string(item_566);
}
list_567.finish();
}
#[allow(unused_mut)]
let mut scope_569 = writer.prefix("TransportProtocol");
if let Some(var_570) = &input.transport_protocol {
scope_569.string(var_570.as_str());
}
#[allow(unused_mut)]
let mut scope_571 = writer.prefix("VpnPort");
if let Some(var_572) = &input.vpn_port {
scope_571.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_572).into()),
);
}
#[allow(unused_mut)]
let mut scope_573 = writer.prefix("Description");
if let Some(var_574) = &input.description {
scope_573.string(var_574);
}
#[allow(unused_mut)]
let mut scope_575 = writer.prefix("SplitTunnel");
if let Some(var_576) = &input.split_tunnel {
scope_575.boolean(*var_576);
}
#[allow(unused_mut)]
let mut scope_577 = writer.prefix("DryRun");
if let Some(var_578) = &input.dry_run {
scope_577.boolean(*var_578);
}
#[allow(unused_mut)]
let mut scope_579 = writer.prefix("ClientToken");
if let Some(var_580) = &input.client_token {
scope_579.string(var_580);
}
#[allow(unused_mut)]
let mut scope_581 = writer.prefix("TagSpecification");
if let Some(var_582) = &input.tag_specifications {
let mut list_584 = scope_581.start_list(true, Some("item"));
for item_583 in var_582 {
#[allow(unused_mut)]
let mut entry_585 = list_584.entry();
crate::query_ser::serialize_structure_crate_model_tag_specification(
entry_585, item_583,
)?;
}
list_584.finish();
}
#[allow(unused_mut)]
let mut scope_586 = writer.prefix("SecurityGroupId");
if let Some(var_587) = &input.security_group_ids {
let mut list_589 = scope_586.start_list(true, Some("item"));
for item_588 in var_587 {
#[allow(unused_mut)]
let mut entry_590 = list_589.entry();
entry_590.string(item_588);
}
list_589.finish();
}
#[allow(unused_mut)]
let mut scope_591 = writer.prefix("VpcId");
if let Some(var_592) = &input.vpc_id {
scope_591.string(var_592);
}
#[allow(unused_mut)]
let mut scope_593 = writer.prefix("SelfServicePortal");
if let Some(var_594) = &input.self_service_portal {
scope_593.string(var_594.as_str());
}
#[allow(unused_mut)]
let mut scope_595 = writer.prefix("ClientConnectOptions");
if let Some(var_596) = &input.client_connect_options {
crate::query_ser::serialize_structure_crate_model_client_connect_options(
scope_595, var_596,
)?;
}
#[allow(unused_mut)]
let mut scope_597 = writer.prefix("SessionTimeoutHours");
if let Some(var_598) = &input.session_timeout_hours {
scope_597.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_598).into()),
);
}
#[allow(unused_mut)]
let mut scope_599 = writer.prefix("ClientLoginBannerOptions");
if let Some(var_600) = &input.client_login_banner_options {
crate::query_ser::serialize_structure_crate_model_client_login_banner_options(
scope_599, var_600,
)?;
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}
Trait Implementations§
source§impl AsRef<str> for TransportProtocol
impl AsRef<str> for TransportProtocol
source§impl Clone for TransportProtocol
impl Clone for TransportProtocol
source§fn clone(&self) -> TransportProtocol
fn clone(&self) -> TransportProtocol
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TransportProtocol
impl Debug for TransportProtocol
source§impl From<&str> for TransportProtocol
impl From<&str> for TransportProtocol
source§impl FromStr for TransportProtocol
impl FromStr for TransportProtocol
source§impl Hash for TransportProtocol
impl Hash for TransportProtocol
source§impl Ord for TransportProtocol
impl Ord for TransportProtocol
source§fn cmp(&self, other: &TransportProtocol) -> Ordering
fn cmp(&self, other: &TransportProtocol) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<TransportProtocol> for TransportProtocol
impl PartialEq<TransportProtocol> for TransportProtocol
source§fn eq(&self, other: &TransportProtocol) -> bool
fn eq(&self, other: &TransportProtocol) -> bool
source§impl PartialOrd<TransportProtocol> for TransportProtocol
impl PartialOrd<TransportProtocol> for TransportProtocol
source§fn partial_cmp(&self, other: &TransportProtocol) -> Option<Ordering>
fn partial_cmp(&self, other: &TransportProtocol) -> 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 TransportProtocol
impl StructuralEq for TransportProtocol
impl StructuralPartialEq for TransportProtocol
Auto Trait Implementations§
impl RefUnwindSafe for TransportProtocol
impl Send for TransportProtocol
impl Sync for TransportProtocol
impl Unpin for TransportProtocol
impl UnwindSafe for TransportProtocol
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.