#[non_exhaustive]
pub enum ConformancePackComplianceType {
    Compliant,
    InsufficientData,
    NonCompliant,
    Unknown(UnknownVariantValue),
}
Expand description

When writing a match expression against ConformancePackComplianceType, 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 conformancepackcompliancetype = unimplemented!();
match conformancepackcompliancetype {
    ConformancePackComplianceType::Compliant => { /* ... */ },
    ConformancePackComplianceType::InsufficientData => { /* ... */ },
    ConformancePackComplianceType::NonCompliant => { /* ... */ },
    other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
    _ => { /* ... */ },
}

The above code demonstrates that when conformancepackcompliancetype represents NewFeature, the execution path will lead to the second last match arm, even though the enum does not contain a variant ConformancePackComplianceType::NewFeature in the current version of SDK. The reason is that the variable other, created by the @ operator, is bound to ConformancePackComplianceType::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 ConformancePackComplianceType::NewFeature is defined. Specifically, when conformancepackcompliancetype represents NewFeature, the execution path will hit the second last match arm as before by virtue of calling as_str on ConformancePackComplianceType::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.
§

Compliant

§

InsufficientData

§

NonCompliant

§

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 9227)
9226
9227
9228
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/json_ser.rs (line 2060)
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
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
pub fn serialize_structure_crate_model_aggregate_conformance_pack_compliance_filters(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::AggregateConformancePackComplianceFilters,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_351) = &input.conformance_pack_name {
        object.key("ConformancePackName").string(var_351.as_str());
    }
    if let Some(var_352) = &input.compliance_type {
        object.key("ComplianceType").string(var_352.as_str());
    }
    if let Some(var_353) = &input.account_id {
        object.key("AccountId").string(var_353.as_str());
    }
    if let Some(var_354) = &input.aws_region {
        object.key("AwsRegion").string(var_354.as_str());
    }
    Ok(())
}

pub fn serialize_structure_crate_model_conformance_pack_compliance_filters(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::ConformancePackComplianceFilters,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_355) = &input.config_rule_names {
        let mut array_356 = object.key("ConfigRuleNames").start_array();
        for item_357 in var_355 {
            {
                array_356.value().string(item_357.as_str());
            }
        }
        array_356.finish();
    }
    if let Some(var_358) = &input.compliance_type {
        object.key("ComplianceType").string(var_358.as_str());
    }
    Ok(())
}

pub fn serialize_structure_crate_model_config_rule_compliance_summary_filters(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::ConfigRuleComplianceSummaryFilters,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_359) = &input.account_id {
        object.key("AccountId").string(var_359.as_str());
    }
    if let Some(var_360) = &input.aws_region {
        object.key("AwsRegion").string(var_360.as_str());
    }
    Ok(())
}

pub fn serialize_structure_crate_model_aggregate_conformance_pack_compliance_summary_filters(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::AggregateConformancePackComplianceSummaryFilters,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_361) = &input.account_id {
        object.key("AccountId").string(var_361.as_str());
    }
    if let Some(var_362) = &input.aws_region {
        object.key("AwsRegion").string(var_362.as_str());
    }
    Ok(())
}

pub fn serialize_structure_crate_model_resource_count_filters(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::ResourceCountFilters,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_363) = &input.resource_type {
        object.key("ResourceType").string(var_363.as_str());
    }
    if let Some(var_364) = &input.account_id {
        object.key("AccountId").string(var_364.as_str());
    }
    if let Some(var_365) = &input.region {
        object.key("Region").string(var_365.as_str());
    }
    Ok(())
}

pub fn serialize_structure_crate_model_conformance_pack_evaluation_filters(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::ConformancePackEvaluationFilters,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_366) = &input.config_rule_names {
        let mut array_367 = object.key("ConfigRuleNames").start_array();
        for item_368 in var_366 {
            {
                array_367.value().string(item_368.as_str());
            }
        }
        array_367.finish();
    }
    if let Some(var_369) = &input.compliance_type {
        object.key("ComplianceType").string(var_369.as_str());
    }
    if let Some(var_370) = &input.resource_type {
        object.key("ResourceType").string(var_370.as_str());
    }
    if let Some(var_371) = &input.resource_ids {
        let mut array_372 = object.key("ResourceIds").start_array();
        for item_373 in var_371 {
            {
                array_372.value().string(item_373.as_str());
            }
        }
        array_372.finish();
    }
    Ok(())
}

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