#[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
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.
§

Branch

§

Efa

§

Trunk

§

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 118610)
118609
118610
118611
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/operation_ser.rs (line 3831)
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))
}

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