#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Tcp

§

Udp

§

Unknown(UnknownVariantValue)

Unknown contains new variants that have been added since this code was generated.

Implementations§

Returns the &str value of the enum member.

Examples found in repository?
src/model.rs (line 109808)
109807
109808
109809
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/operation_ser.rs (line 2052)
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))
}

Returns all the &str values of the enum members.

Trait Implementations§

Converts this type into a shared reference of the (usually inferred) input type.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more