#[non_exhaustive]
pub enum AddressFamily {
    IPv4,
    IPv6,
    Unknown(UnknownVariantValue),
}
Expand description

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

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

IPv4

§

IPv6

§

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 644)
643
644
645
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/json_ser.rs (line 1246)
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
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
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
pub fn serialize_structure_crate_model_new_private_virtual_interface_allocation(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::NewPrivateVirtualInterfaceAllocation,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_217) = &input.virtual_interface_name {
        object.key("virtualInterfaceName").string(var_217.as_str());
    }
    {
        object.key("vlan").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((input.vlan).into()),
        );
    }
    {
        object.key("asn").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((input.asn).into()),
        );
    }
    if let Some(var_218) = &input.mtu {
        object.key("mtu").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_218).into()),
        );
    }
    if let Some(var_219) = &input.auth_key {
        object.key("authKey").string(var_219.as_str());
    }
    if let Some(var_220) = &input.amazon_address {
        object.key("amazonAddress").string(var_220.as_str());
    }
    if let Some(var_221) = &input.address_family {
        object.key("addressFamily").string(var_221.as_str());
    }
    if let Some(var_222) = &input.customer_address {
        object.key("customerAddress").string(var_222.as_str());
    }
    if let Some(var_223) = &input.tags {
        let mut array_224 = object.key("tags").start_array();
        for item_225 in var_223 {
            {
                #[allow(unused_mut)]
                let mut object_226 = array_224.value().start_object();
                crate::json_ser::serialize_structure_crate_model_tag(&mut object_226, item_225)?;
                object_226.finish();
            }
        }
        array_224.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_model_new_public_virtual_interface_allocation(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::NewPublicVirtualInterfaceAllocation,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_227) = &input.virtual_interface_name {
        object.key("virtualInterfaceName").string(var_227.as_str());
    }
    {
        object.key("vlan").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((input.vlan).into()),
        );
    }
    {
        object.key("asn").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((input.asn).into()),
        );
    }
    if let Some(var_228) = &input.auth_key {
        object.key("authKey").string(var_228.as_str());
    }
    if let Some(var_229) = &input.amazon_address {
        object.key("amazonAddress").string(var_229.as_str());
    }
    if let Some(var_230) = &input.customer_address {
        object.key("customerAddress").string(var_230.as_str());
    }
    if let Some(var_231) = &input.address_family {
        object.key("addressFamily").string(var_231.as_str());
    }
    if let Some(var_232) = &input.route_filter_prefixes {
        let mut array_233 = object.key("routeFilterPrefixes").start_array();
        for item_234 in var_232 {
            {
                #[allow(unused_mut)]
                let mut object_235 = array_233.value().start_object();
                crate::json_ser::serialize_structure_crate_model_route_filter_prefix(
                    &mut object_235,
                    item_234,
                )?;
                object_235.finish();
            }
        }
        array_233.finish();
    }
    if let Some(var_236) = &input.tags {
        let mut array_237 = object.key("tags").start_array();
        for item_238 in var_236 {
            {
                #[allow(unused_mut)]
                let mut object_239 = array_237.value().start_object();
                crate::json_ser::serialize_structure_crate_model_tag(&mut object_239, item_238)?;
                object_239.finish();
            }
        }
        array_237.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_model_new_transit_virtual_interface_allocation(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::NewTransitVirtualInterfaceAllocation,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_240) = &input.virtual_interface_name {
        object.key("virtualInterfaceName").string(var_240.as_str());
    }
    if input.vlan != 0 {
        object.key("vlan").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((input.vlan).into()),
        );
    }
    if input.asn != 0 {
        object.key("asn").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((input.asn).into()),
        );
    }
    if let Some(var_241) = &input.mtu {
        object.key("mtu").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_241).into()),
        );
    }
    if let Some(var_242) = &input.auth_key {
        object.key("authKey").string(var_242.as_str());
    }
    if let Some(var_243) = &input.amazon_address {
        object.key("amazonAddress").string(var_243.as_str());
    }
    if let Some(var_244) = &input.customer_address {
        object.key("customerAddress").string(var_244.as_str());
    }
    if let Some(var_245) = &input.address_family {
        object.key("addressFamily").string(var_245.as_str());
    }
    if let Some(var_246) = &input.tags {
        let mut array_247 = object.key("tags").start_array();
        for item_248 in var_246 {
            {
                #[allow(unused_mut)]
                let mut object_249 = array_247.value().start_object();
                crate::json_ser::serialize_structure_crate_model_tag(&mut object_249, item_248)?;
                object_249.finish();
            }
        }
        array_247.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_model_new_bgp_peer(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::NewBgpPeer,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if input.asn != 0 {
        object.key("asn").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((input.asn).into()),
        );
    }
    if let Some(var_250) = &input.auth_key {
        object.key("authKey").string(var_250.as_str());
    }
    if let Some(var_251) = &input.address_family {
        object.key("addressFamily").string(var_251.as_str());
    }
    if let Some(var_252) = &input.amazon_address {
        object.key("amazonAddress").string(var_252.as_str());
    }
    if let Some(var_253) = &input.customer_address {
        object.key("customerAddress").string(var_253.as_str());
    }
    Ok(())
}

pub fn serialize_structure_crate_model_new_private_virtual_interface(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::NewPrivateVirtualInterface,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_254) = &input.virtual_interface_name {
        object.key("virtualInterfaceName").string(var_254.as_str());
    }
    {
        object.key("vlan").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((input.vlan).into()),
        );
    }
    {
        object.key("asn").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((input.asn).into()),
        );
    }
    if let Some(var_255) = &input.mtu {
        object.key("mtu").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_255).into()),
        );
    }
    if let Some(var_256) = &input.auth_key {
        object.key("authKey").string(var_256.as_str());
    }
    if let Some(var_257) = &input.amazon_address {
        object.key("amazonAddress").string(var_257.as_str());
    }
    if let Some(var_258) = &input.customer_address {
        object.key("customerAddress").string(var_258.as_str());
    }
    if let Some(var_259) = &input.address_family {
        object.key("addressFamily").string(var_259.as_str());
    }
    if let Some(var_260) = &input.virtual_gateway_id {
        object.key("virtualGatewayId").string(var_260.as_str());
    }
    if let Some(var_261) = &input.direct_connect_gateway_id {
        object
            .key("directConnectGatewayId")
            .string(var_261.as_str());
    }
    if let Some(var_262) = &input.tags {
        let mut array_263 = object.key("tags").start_array();
        for item_264 in var_262 {
            {
                #[allow(unused_mut)]
                let mut object_265 = array_263.value().start_object();
                crate::json_ser::serialize_structure_crate_model_tag(&mut object_265, item_264)?;
                object_265.finish();
            }
        }
        array_263.finish();
    }
    if let Some(var_266) = &input.enable_site_link {
        object.key("enableSiteLink").boolean(*var_266);
    }
    Ok(())
}

pub fn serialize_structure_crate_model_new_public_virtual_interface(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::NewPublicVirtualInterface,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_267) = &input.virtual_interface_name {
        object.key("virtualInterfaceName").string(var_267.as_str());
    }
    {
        object.key("vlan").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((input.vlan).into()),
        );
    }
    {
        object.key("asn").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((input.asn).into()),
        );
    }
    if let Some(var_268) = &input.auth_key {
        object.key("authKey").string(var_268.as_str());
    }
    if let Some(var_269) = &input.amazon_address {
        object.key("amazonAddress").string(var_269.as_str());
    }
    if let Some(var_270) = &input.customer_address {
        object.key("customerAddress").string(var_270.as_str());
    }
    if let Some(var_271) = &input.address_family {
        object.key("addressFamily").string(var_271.as_str());
    }
    if let Some(var_272) = &input.route_filter_prefixes {
        let mut array_273 = object.key("routeFilterPrefixes").start_array();
        for item_274 in var_272 {
            {
                #[allow(unused_mut)]
                let mut object_275 = array_273.value().start_object();
                crate::json_ser::serialize_structure_crate_model_route_filter_prefix(
                    &mut object_275,
                    item_274,
                )?;
                object_275.finish();
            }
        }
        array_273.finish();
    }
    if let Some(var_276) = &input.tags {
        let mut array_277 = object.key("tags").start_array();
        for item_278 in var_276 {
            {
                #[allow(unused_mut)]
                let mut object_279 = array_277.value().start_object();
                crate::json_ser::serialize_structure_crate_model_tag(&mut object_279, item_278)?;
                object_279.finish();
            }
        }
        array_277.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_model_new_transit_virtual_interface(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::NewTransitVirtualInterface,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_280) = &input.virtual_interface_name {
        object.key("virtualInterfaceName").string(var_280.as_str());
    }
    if input.vlan != 0 {
        object.key("vlan").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((input.vlan).into()),
        );
    }
    if input.asn != 0 {
        object.key("asn").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((input.asn).into()),
        );
    }
    if let Some(var_281) = &input.mtu {
        object.key("mtu").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_281).into()),
        );
    }
    if let Some(var_282) = &input.auth_key {
        object.key("authKey").string(var_282.as_str());
    }
    if let Some(var_283) = &input.amazon_address {
        object.key("amazonAddress").string(var_283.as_str());
    }
    if let Some(var_284) = &input.customer_address {
        object.key("customerAddress").string(var_284.as_str());
    }
    if let Some(var_285) = &input.address_family {
        object.key("addressFamily").string(var_285.as_str());
    }
    if let Some(var_286) = &input.direct_connect_gateway_id {
        object
            .key("directConnectGatewayId")
            .string(var_286.as_str());
    }
    if let Some(var_287) = &input.tags {
        let mut array_288 = object.key("tags").start_array();
        for item_289 in var_287 {
            {
                #[allow(unused_mut)]
                let mut object_290 = array_288.value().start_object();
                crate::json_ser::serialize_structure_crate_model_tag(&mut object_290, item_289)?;
                object_290.finish();
            }
        }
        array_288.finish();
    }
    if let Some(var_291) = &input.enable_site_link {
        object.key("enableSiteLink").boolean(*var_291);
    }
    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