Enum aws_sdk_s3control::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
1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204
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_120) = &input.expiration {
let inner_writer = scope.start_el("Expiration");
crate::xml_ser::serialize_structure_crate_model_lifecycle_expiration(var_120, inner_writer)?
}
if let Some(var_121) = &input.id {
let mut inner_writer = scope.start_el("ID").finish();
inner_writer.data(var_121.as_str());
}
if let Some(var_122) = &input.filter {
let inner_writer = scope.start_el("Filter");
crate::xml_ser::serialize_structure_crate_model_lifecycle_rule_filter(
var_122,
inner_writer,
)?
}
if let Some(var_123) = &input.status {
let mut inner_writer = scope.start_el("Status").finish();
inner_writer.data(var_123.as_str());
}
if let Some(var_124) = &input.transitions {
let mut inner_writer = scope.start_el("Transitions").finish();
for list_item_125 in var_124 {
{
let inner_writer = inner_writer.start_el("Transition");
crate::xml_ser::serialize_structure_crate_model_transition(
list_item_125,
inner_writer,
)?
}
}
}
if let Some(var_126) = &input.noncurrent_version_transitions {
let mut inner_writer = scope.start_el("NoncurrentVersionTransitions").finish();
for list_item_127 in var_126 {
{
let inner_writer = inner_writer.start_el("NoncurrentVersionTransition");
crate::xml_ser::serialize_structure_crate_model_noncurrent_version_transition(
list_item_127,
inner_writer,
)?
}
}
}
if let Some(var_128) = &input.noncurrent_version_expiration {
let inner_writer = scope.start_el("NoncurrentVersionExpiration");
crate::xml_ser::serialize_structure_crate_model_noncurrent_version_expiration(
var_128,
inner_writer,
)?
}
if let Some(var_129) = &input.abort_incomplete_multipart_upload {
let inner_writer = scope.start_el("AbortIncompleteMultipartUpload");
crate::xml_ser::serialize_structure_crate_model_abort_incomplete_multipart_upload(
var_129,
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.