Enum aws_sdk_s3::model::ExpirationStatus
source · #[non_exhaustive]
pub enum ExpirationStatus {
Disabled,
Enabled,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against ExpirationStatus
, 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 expirationstatus = unimplemented!();
match expirationstatus {
ExpirationStatus::Disabled => { /* ... */ },
ExpirationStatus::Enabled => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when expirationstatus
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant ExpirationStatus::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
ExpirationStatus::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 ExpirationStatus::NewFeature
is defined.
Specifically, when expirationstatus
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on ExpirationStatus::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
Disabled
Enabled
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl ExpirationStatus
impl ExpirationStatus
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
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
pub fn serialize_structure_crate_model_lifecycle_rule(
input: &crate::model::LifecycleRule,
writer: aws_smithy_xml::encode::ElWriter,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
#[allow(unused_mut)]
let mut scope = writer.finish();
if let Some(var_108) = &input.expiration {
let inner_writer = scope.start_el("Expiration");
crate::xml_ser::serialize_structure_crate_model_lifecycle_expiration(var_108, inner_writer)?
}
if let Some(var_109) = &input.id {
let mut inner_writer = scope.start_el("ID").finish();
inner_writer.data(var_109.as_str());
}
if let Some(var_110) = &input.prefix {
let mut inner_writer = scope.start_el("Prefix").finish();
inner_writer.data(var_110.as_str());
}
if let Some(var_111) = &input.filter {
let inner_writer = scope.start_el("Filter");
crate::xml_ser::serialize_union_crate_model_lifecycle_rule_filter(var_111, inner_writer)?
}
if let Some(var_112) = &input.status {
let mut inner_writer = scope.start_el("Status").finish();
inner_writer.data(var_112.as_str());
}
if let Some(var_113) = &input.transitions {
for list_item_114 in var_113 {
{
let inner_writer = scope.start_el("Transition");
crate::xml_ser::serialize_structure_crate_model_transition(
list_item_114,
inner_writer,
)?
}
}
}
if let Some(var_115) = &input.noncurrent_version_transitions {
for list_item_116 in var_115 {
{
let inner_writer = scope.start_el("NoncurrentVersionTransition");
crate::xml_ser::serialize_structure_crate_model_noncurrent_version_transition(
list_item_116,
inner_writer,
)?
}
}
}
if let Some(var_117) = &input.noncurrent_version_expiration {
let inner_writer = scope.start_el("NoncurrentVersionExpiration");
crate::xml_ser::serialize_structure_crate_model_noncurrent_version_expiration(
var_117,
inner_writer,
)?
}
if let Some(var_118) = &input.abort_incomplete_multipart_upload {
let inner_writer = scope.start_el("AbortIncompleteMultipartUpload");
crate::xml_ser::serialize_structure_crate_model_abort_incomplete_multipart_upload(
var_118,
inner_writer,
)?
}
scope.finish();
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for ExpirationStatus
impl AsRef<str> for ExpirationStatus
source§impl Clone for ExpirationStatus
impl Clone for ExpirationStatus
source§fn clone(&self) -> ExpirationStatus
fn clone(&self) -> ExpirationStatus
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ExpirationStatus
impl Debug for ExpirationStatus
source§impl From<&str> for ExpirationStatus
impl From<&str> for ExpirationStatus
source§impl FromStr for ExpirationStatus
impl FromStr for ExpirationStatus
source§impl Hash for ExpirationStatus
impl Hash for ExpirationStatus
source§impl Ord for ExpirationStatus
impl Ord for ExpirationStatus
source§fn cmp(&self, other: &ExpirationStatus) -> Ordering
fn cmp(&self, other: &ExpirationStatus) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<ExpirationStatus> for ExpirationStatus
impl PartialEq<ExpirationStatus> for ExpirationStatus
source§fn eq(&self, other: &ExpirationStatus) -> bool
fn eq(&self, other: &ExpirationStatus) -> bool
source§impl PartialOrd<ExpirationStatus> for ExpirationStatus
impl PartialOrd<ExpirationStatus> for ExpirationStatus
source§fn partial_cmp(&self, other: &ExpirationStatus) -> Option<Ordering>
fn partial_cmp(&self, other: &ExpirationStatus) -> 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 ExpirationStatus
impl StructuralEq for ExpirationStatus
impl StructuralPartialEq for ExpirationStatus
Auto Trait Implementations§
impl RefUnwindSafe for ExpirationStatus
impl Send for ExpirationStatus
impl Sync for ExpirationStatus
impl Unpin for ExpirationStatus
impl UnwindSafe for ExpirationStatus
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.