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

Ec2

§

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 45859)
45858
45859
45860
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/operation_ser.rs (line 3021)
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))
}

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