#[non_exhaustive]
pub enum RuleOperator {
    Contains,
    Equals,
    GreaterThan,
    GreaterThanOrEquals,
    In,
    LessThan,
    LessThanOrEquals,
    NotIn,
    Unknown(UnknownVariantValue),
}
Expand description

When writing a match expression against RuleOperator, 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 ruleoperator = unimplemented!();
match ruleoperator {
    RuleOperator::Contains => { /* ... */ },
    RuleOperator::Equals => { /* ... */ },
    RuleOperator::GreaterThan => { /* ... */ },
    RuleOperator::GreaterThanOrEquals => { /* ... */ },
    RuleOperator::In => { /* ... */ },
    RuleOperator::LessThan => { /* ... */ },
    RuleOperator::LessThanOrEquals => { /* ... */ },
    RuleOperator::NotIn => { /* ... */ },
    other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
    _ => { /* ... */ },
}

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

Contains

§

Equals

§

GreaterThan

§

GreaterThanOrEquals

§

In

§

LessThan

§

LessThanOrEquals

§

NotIn

§

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 2805)
2804
2805
2806
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/json_ser.rs (line 1379)
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
pub fn serialize_structure_crate_model_rule(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::Rule,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_234) = &input.attribute {
        object.key("attribute").string(var_234.as_str());
    }
    if let Some(var_235) = &input.operator {
        object.key("operator").string(var_235.as_str());
    }
    if let Some(var_236) = &input.value {
        object.key("value").string(var_236.as_str());
    }
    Ok(())
}

pub fn serialize_structure_crate_model_vpc_config(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::VpcConfig,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_237) = &input.security_group_ids {
        let mut array_238 = object.key("securityGroupIds").start_array();
        for item_239 in var_237 {
            {
                array_238.value().string(item_239.as_str());
            }
        }
        array_238.finish();
    }
    if let Some(var_240) = &input.subnet_ids {
        let mut array_241 = object.key("subnetIds").start_array();
        for item_242 in var_240 {
            {
                array_241.value().string(item_242.as_str());
            }
        }
        array_241.finish();
    }
    if let Some(var_243) = &input.vpc_id {
        object.key("vpcId").string(var_243.as_str());
    }
    Ok(())
}

pub fn serialize_structure_crate_model_create_remote_access_session_configuration(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::CreateRemoteAccessSessionConfiguration,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_244) = &input.billing_method {
        object.key("billingMethod").string(var_244.as_str());
    }
    if let Some(var_245) = &input.vpce_configuration_arns {
        let mut array_246 = object.key("vpceConfigurationArns").start_array();
        for item_247 in var_245 {
            {
                array_246.value().string(item_247.as_str());
            }
        }
        array_246.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_model_test_grid_vpc_config(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::TestGridVpcConfig,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_248) = &input.security_group_ids {
        let mut array_249 = object.key("securityGroupIds").start_array();
        for item_250 in var_248 {
            {
                array_249.value().string(item_250.as_str());
            }
        }
        array_249.finish();
    }
    if let Some(var_251) = &input.subnet_ids {
        let mut array_252 = object.key("subnetIds").start_array();
        for item_253 in var_251 {
            {
                array_252.value().string(item_253.as_str());
            }
        }
        array_252.finish();
    }
    if let Some(var_254) = &input.vpc_id {
        object.key("vpcId").string(var_254.as_str());
    }
    Ok(())
}

pub fn serialize_structure_crate_model_schedule_run_test(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::ScheduleRunTest,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_255) = &input.r#type {
        object.key("type").string(var_255.as_str());
    }
    if let Some(var_256) = &input.test_package_arn {
        object.key("testPackageArn").string(var_256.as_str());
    }
    if let Some(var_257) = &input.test_spec_arn {
        object.key("testSpecArn").string(var_257.as_str());
    }
    if let Some(var_258) = &input.filter {
        object.key("filter").string(var_258.as_str());
    }
    if let Some(var_259) = &input.parameters {
        #[allow(unused_mut)]
        let mut object_260 = object.key("parameters").start_object();
        for (key_261, value_262) in var_259 {
            {
                object_260.key(key_261.as_str()).string(value_262.as_str());
            }
        }
        object_260.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_model_schedule_run_configuration(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::ScheduleRunConfiguration,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_263) = &input.extra_data_package_arn {
        object.key("extraDataPackageArn").string(var_263.as_str());
    }
    if let Some(var_264) = &input.network_profile_arn {
        object.key("networkProfileArn").string(var_264.as_str());
    }
    if let Some(var_265) = &input.locale {
        object.key("locale").string(var_265.as_str());
    }
    if let Some(var_266) = &input.location {
        #[allow(unused_mut)]
        let mut object_267 = object.key("location").start_object();
        crate::json_ser::serialize_structure_crate_model_location(&mut object_267, var_266)?;
        object_267.finish();
    }
    if let Some(var_268) = &input.vpce_configuration_arns {
        let mut array_269 = object.key("vpceConfigurationArns").start_array();
        for item_270 in var_268 {
            {
                array_269.value().string(item_270.as_str());
            }
        }
        array_269.finish();
    }
    if let Some(var_271) = &input.customer_artifact_paths {
        #[allow(unused_mut)]
        let mut object_272 = object.key("customerArtifactPaths").start_object();
        crate::json_ser::serialize_structure_crate_model_customer_artifact_paths(
            &mut object_272,
            var_271,
        )?;
        object_272.finish();
    }
    if let Some(var_273) = &input.radios {
        #[allow(unused_mut)]
        let mut object_274 = object.key("radios").start_object();
        crate::json_ser::serialize_structure_crate_model_radios(&mut object_274, var_273)?;
        object_274.finish();
    }
    if let Some(var_275) = &input.auxiliary_apps {
        let mut array_276 = object.key("auxiliaryApps").start_array();
        for item_277 in var_275 {
            {
                array_276.value().string(item_277.as_str());
            }
        }
        array_276.finish();
    }
    if let Some(var_278) = &input.billing_method {
        object.key("billingMethod").string(var_278.as_str());
    }
    Ok(())
}

pub fn serialize_structure_crate_model_device_filter(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::DeviceFilter,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_279) = &input.attribute {
        object.key("attribute").string(var_279.as_str());
    }
    if let Some(var_280) = &input.operator {
        object.key("operator").string(var_280.as_str());
    }
    if let Some(var_281) = &input.values {
        let mut array_282 = object.key("values").start_array();
        for item_283 in var_281 {
            {
                array_282.value().string(item_283.as_str());
            }
        }
        array_282.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