#[non_exhaustive]
pub enum TcpRetryPolicyEvent {
ConnectionError,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against TcpRetryPolicyEvent
, 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 tcpretrypolicyevent = unimplemented!();
match tcpretrypolicyevent {
TcpRetryPolicyEvent::ConnectionError => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when tcpretrypolicyevent
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant TcpRetryPolicyEvent::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
TcpRetryPolicyEvent::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 TcpRetryPolicyEvent::NewFeature
is defined.
Specifically, when tcpretrypolicyevent
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on TcpRetryPolicyEvent::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
ConnectionError
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl TcpRetryPolicyEvent
impl TcpRetryPolicyEvent
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the &str
value of the enum member.
Examples found in repository?
More examples
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
pub fn serialize_structure_crate_model_http_retry_policy(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::HttpRetryPolicy,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_251) = &input.per_retry_timeout {
#[allow(unused_mut)]
let mut object_252 = object.key("perRetryTimeout").start_object();
crate::json_ser::serialize_structure_crate_model_duration(&mut object_252, var_251)?;
object_252.finish();
}
if let Some(var_253) = &input.max_retries {
object.key("maxRetries").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_253).into()),
);
}
if let Some(var_254) = &input.http_retry_events {
let mut array_255 = object.key("httpRetryEvents").start_array();
for item_256 in var_254 {
{
array_255.value().string(item_256.as_str());
}
}
array_255.finish();
}
if let Some(var_257) = &input.tcp_retry_events {
let mut array_258 = object.key("tcpRetryEvents").start_array();
for item_259 in var_257 {
{
array_258.value().string(item_259.as_str());
}
}
array_258.finish();
}
Ok(())
}
pub fn serialize_structure_crate_model_http_timeout(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::HttpTimeout,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_260) = &input.per_request {
#[allow(unused_mut)]
let mut object_261 = object.key("perRequest").start_object();
crate::json_ser::serialize_structure_crate_model_duration(&mut object_261, var_260)?;
object_261.finish();
}
if let Some(var_262) = &input.idle {
#[allow(unused_mut)]
let mut object_263 = object.key("idle").start_object();
crate::json_ser::serialize_structure_crate_model_duration(&mut object_263, var_262)?;
object_263.finish();
}
Ok(())
}
pub fn serialize_structure_crate_model_tcp_route_action(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::TcpRouteAction,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_264) = &input.weighted_targets {
let mut array_265 = object.key("weightedTargets").start_array();
for item_266 in var_264 {
{
#[allow(unused_mut)]
let mut object_267 = array_265.value().start_object();
crate::json_ser::serialize_structure_crate_model_weighted_target(
&mut object_267,
item_266,
)?;
object_267.finish();
}
}
array_265.finish();
}
Ok(())
}
pub fn serialize_structure_crate_model_tcp_timeout(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::TcpTimeout,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_268) = &input.idle {
#[allow(unused_mut)]
let mut object_269 = object.key("idle").start_object();
crate::json_ser::serialize_structure_crate_model_duration(&mut object_269, var_268)?;
object_269.finish();
}
Ok(())
}
pub fn serialize_structure_crate_model_tcp_route_match(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::TcpRouteMatch,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_270) = &input.port {
object.key("port").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_270).into()),
);
}
Ok(())
}
pub fn serialize_structure_crate_model_grpc_route_action(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::GrpcRouteAction,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_271) = &input.weighted_targets {
let mut array_272 = object.key("weightedTargets").start_array();
for item_273 in var_271 {
{
#[allow(unused_mut)]
let mut object_274 = array_272.value().start_object();
crate::json_ser::serialize_structure_crate_model_weighted_target(
&mut object_274,
item_273,
)?;
object_274.finish();
}
}
array_272.finish();
}
Ok(())
}
pub fn serialize_structure_crate_model_grpc_route_match(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::GrpcRouteMatch,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_275) = &input.service_name {
object.key("serviceName").string(var_275.as_str());
}
if let Some(var_276) = &input.method_name {
object.key("methodName").string(var_276.as_str());
}
if let Some(var_277) = &input.metadata {
let mut array_278 = object.key("metadata").start_array();
for item_279 in var_277 {
{
#[allow(unused_mut)]
let mut object_280 = array_278.value().start_object();
crate::json_ser::serialize_structure_crate_model_grpc_route_metadata(
&mut object_280,
item_279,
)?;
object_280.finish();
}
}
array_278.finish();
}
if let Some(var_281) = &input.port {
object.key("port").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_281).into()),
);
}
Ok(())
}
pub fn serialize_structure_crate_model_grpc_retry_policy(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::GrpcRetryPolicy,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_282) = &input.per_retry_timeout {
#[allow(unused_mut)]
let mut object_283 = object.key("perRetryTimeout").start_object();
crate::json_ser::serialize_structure_crate_model_duration(&mut object_283, var_282)?;
object_283.finish();
}
if let Some(var_284) = &input.max_retries {
object.key("maxRetries").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_284).into()),
);
}
if let Some(var_285) = &input.http_retry_events {
let mut array_286 = object.key("httpRetryEvents").start_array();
for item_287 in var_285 {
{
array_286.value().string(item_287.as_str());
}
}
array_286.finish();
}
if let Some(var_288) = &input.tcp_retry_events {
let mut array_289 = object.key("tcpRetryEvents").start_array();
for item_290 in var_288 {
{
array_289.value().string(item_290.as_str());
}
}
array_289.finish();
}
if let Some(var_291) = &input.grpc_retry_events {
let mut array_292 = object.key("grpcRetryEvents").start_array();
for item_293 in var_291 {
{
array_292.value().string(item_293.as_str());
}
}
array_292.finish();
}
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for TcpRetryPolicyEvent
impl AsRef<str> for TcpRetryPolicyEvent
source§impl Clone for TcpRetryPolicyEvent
impl Clone for TcpRetryPolicyEvent
source§fn clone(&self) -> TcpRetryPolicyEvent
fn clone(&self) -> TcpRetryPolicyEvent
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TcpRetryPolicyEvent
impl Debug for TcpRetryPolicyEvent
source§impl From<&str> for TcpRetryPolicyEvent
impl From<&str> for TcpRetryPolicyEvent
source§impl FromStr for TcpRetryPolicyEvent
impl FromStr for TcpRetryPolicyEvent
source§impl Hash for TcpRetryPolicyEvent
impl Hash for TcpRetryPolicyEvent
source§impl Ord for TcpRetryPolicyEvent
impl Ord for TcpRetryPolicyEvent
source§fn cmp(&self, other: &TcpRetryPolicyEvent) -> Ordering
fn cmp(&self, other: &TcpRetryPolicyEvent) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<TcpRetryPolicyEvent> for TcpRetryPolicyEvent
impl PartialEq<TcpRetryPolicyEvent> for TcpRetryPolicyEvent
source§fn eq(&self, other: &TcpRetryPolicyEvent) -> bool
fn eq(&self, other: &TcpRetryPolicyEvent) -> bool
source§impl PartialOrd<TcpRetryPolicyEvent> for TcpRetryPolicyEvent
impl PartialOrd<TcpRetryPolicyEvent> for TcpRetryPolicyEvent
source§fn partial_cmp(&self, other: &TcpRetryPolicyEvent) -> Option<Ordering>
fn partial_cmp(&self, other: &TcpRetryPolicyEvent) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Eq for TcpRetryPolicyEvent
impl StructuralEq for TcpRetryPolicyEvent
impl StructuralPartialEq for TcpRetryPolicyEvent
Auto Trait Implementations§
impl RefUnwindSafe for TcpRetryPolicyEvent
impl Send for TcpRetryPolicyEvent
impl Sync for TcpRetryPolicyEvent
impl Unpin for TcpRetryPolicyEvent
impl UnwindSafe for TcpRetryPolicyEvent
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.