#[non_exhaustive]
pub enum ComparisonOperator {
Show 14 variants BeginsWith, Between, Contains, Eq, Ge, Gt, In, Le, Lt, Ne, NotContains, NotNull, Null, Unknown(UnknownVariantValue),
}
Expand description

When writing a match expression against ComparisonOperator, 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 comparisonoperator = unimplemented!();
match comparisonoperator {
    ComparisonOperator::BeginsWith => { /* ... */ },
    ComparisonOperator::Between => { /* ... */ },
    ComparisonOperator::Contains => { /* ... */ },
    ComparisonOperator::Eq => { /* ... */ },
    ComparisonOperator::Ge => { /* ... */ },
    ComparisonOperator::Gt => { /* ... */ },
    ComparisonOperator::In => { /* ... */ },
    ComparisonOperator::Le => { /* ... */ },
    ComparisonOperator::Lt => { /* ... */ },
    ComparisonOperator::Ne => { /* ... */ },
    ComparisonOperator::NotContains => { /* ... */ },
    ComparisonOperator::NotNull => { /* ... */ },
    ComparisonOperator::Null => { /* ... */ },
    other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
    _ => { /* ... */ },
}

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

BeginsWith

§

Between

§

Contains

§

Eq

§

Ge

§

Gt

§

In

§

Le

§

Lt

§

Ne

§

NotContains

§

NotNull

§

Null

§

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 7939)
7938
7939
7940
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/json_ser.rs (line 2174)
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
pub fn serialize_structure_crate_model_expected_attribute_value(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::ExpectedAttributeValue,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_479) = &input.value {
        #[allow(unused_mut)]
        let mut object_480 = object.key("Value").start_object();
        crate::json_ser::serialize_union_crate_model_attribute_value(&mut object_480, var_479)?;
        object_480.finish();
    }
    if let Some(var_481) = &input.exists {
        object.key("Exists").boolean(*var_481);
    }
    if let Some(var_482) = &input.comparison_operator {
        object.key("ComparisonOperator").string(var_482.as_str());
    }
    if let Some(var_483) = &input.attribute_value_list {
        let mut array_484 = object.key("AttributeValueList").start_array();
        for item_485 in var_483 {
            {
                #[allow(unused_mut)]
                let mut object_486 = array_484.value().start_object();
                crate::json_ser::serialize_union_crate_model_attribute_value(
                    &mut object_486,
                    item_485,
                )?;
                object_486.finish();
            }
        }
        array_484.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_model_parameterized_statement(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::ParameterizedStatement,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_487) = &input.statement {
        object.key("Statement").string(var_487.as_str());
    }
    if let Some(var_488) = &input.parameters {
        let mut array_489 = object.key("Parameters").start_array();
        for item_490 in var_488 {
            {
                #[allow(unused_mut)]
                let mut object_491 = array_489.value().start_object();
                crate::json_ser::serialize_union_crate_model_attribute_value(
                    &mut object_491,
                    item_490,
                )?;
                object_491.finish();
            }
        }
        array_489.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_model_s3_bucket_source(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::S3BucketSource,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_492) = &input.s3_bucket_owner {
        object.key("S3BucketOwner").string(var_492.as_str());
    }
    if let Some(var_493) = &input.s3_bucket {
        object.key("S3Bucket").string(var_493.as_str());
    }
    if let Some(var_494) = &input.s3_key_prefix {
        object.key("S3KeyPrefix").string(var_494.as_str());
    }
    Ok(())
}

pub fn serialize_structure_crate_model_input_format_options(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::InputFormatOptions,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_495) = &input.csv {
        #[allow(unused_mut)]
        let mut object_496 = object.key("Csv").start_object();
        crate::json_ser::serialize_structure_crate_model_csv_options(&mut object_496, var_495)?;
        object_496.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_model_table_creation_parameters(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::TableCreationParameters,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_497) = &input.table_name {
        object.key("TableName").string(var_497.as_str());
    }
    if let Some(var_498) = &input.attribute_definitions {
        let mut array_499 = object.key("AttributeDefinitions").start_array();
        for item_500 in var_498 {
            {
                #[allow(unused_mut)]
                let mut object_501 = array_499.value().start_object();
                crate::json_ser::serialize_structure_crate_model_attribute_definition(
                    &mut object_501,
                    item_500,
                )?;
                object_501.finish();
            }
        }
        array_499.finish();
    }
    if let Some(var_502) = &input.key_schema {
        let mut array_503 = object.key("KeySchema").start_array();
        for item_504 in var_502 {
            {
                #[allow(unused_mut)]
                let mut object_505 = array_503.value().start_object();
                crate::json_ser::serialize_structure_crate_model_key_schema_element(
                    &mut object_505,
                    item_504,
                )?;
                object_505.finish();
            }
        }
        array_503.finish();
    }
    if let Some(var_506) = &input.billing_mode {
        object.key("BillingMode").string(var_506.as_str());
    }
    if let Some(var_507) = &input.provisioned_throughput {
        #[allow(unused_mut)]
        let mut object_508 = object.key("ProvisionedThroughput").start_object();
        crate::json_ser::serialize_structure_crate_model_provisioned_throughput(
            &mut object_508,
            var_507,
        )?;
        object_508.finish();
    }
    if let Some(var_509) = &input.sse_specification {
        #[allow(unused_mut)]
        let mut object_510 = object.key("SSESpecification").start_object();
        crate::json_ser::serialize_structure_crate_model_sse_specification(
            &mut object_510,
            var_509,
        )?;
        object_510.finish();
    }
    if let Some(var_511) = &input.global_secondary_indexes {
        let mut array_512 = object.key("GlobalSecondaryIndexes").start_array();
        for item_513 in var_511 {
            {
                #[allow(unused_mut)]
                let mut object_514 = array_512.value().start_object();
                crate::json_ser::serialize_structure_crate_model_global_secondary_index(
                    &mut object_514,
                    item_513,
                )?;
                object_514.finish();
            }
        }
        array_512.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_model_condition(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::Condition,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_515) = &input.attribute_value_list {
        let mut array_516 = object.key("AttributeValueList").start_array();
        for item_517 in var_515 {
            {
                #[allow(unused_mut)]
                let mut object_518 = array_516.value().start_object();
                crate::json_ser::serialize_union_crate_model_attribute_value(
                    &mut object_518,
                    item_517,
                )?;
                object_518.finish();
            }
        }
        array_516.finish();
    }
    if let Some(var_519) = &input.comparison_operator {
        object.key("ComparisonOperator").string(var_519.as_str());
    }
    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