#[non_exhaustive]
pub enum ReplicationStatus {
Completed,
Failed,
None,
Replica,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against ReplicationStatus
, 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 replicationstatus = unimplemented!();
match replicationstatus {
ReplicationStatus::Completed => { /* ... */ },
ReplicationStatus::Failed => { /* ... */ },
ReplicationStatus::None => { /* ... */ },
ReplicationStatus::Replica => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when replicationstatus
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant ReplicationStatus::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
ReplicationStatus::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 ReplicationStatus::NewFeature
is defined.
Specifically, when replicationstatus
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on ReplicationStatus::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
Completed
Failed
None
Replica
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl ReplicationStatus
impl ReplicationStatus
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
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
pub fn serialize_structure_crate_model_job_manifest_generator_filter(
input: &crate::model::JobManifestGeneratorFilter,
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_148) = &input.eligible_for_replication {
let mut inner_writer = scope.start_el("EligibleForReplication").finish();
inner_writer.data(aws_smithy_types::primitive::Encoder::from(*var_148).encode());
}
if let Some(var_149) = &input.created_after {
let mut inner_writer = scope.start_el("CreatedAfter").finish();
inner_writer.data(
var_149
.fmt(aws_smithy_types::date_time::Format::DateTime)?
.as_ref(),
);
}
if let Some(var_150) = &input.created_before {
let mut inner_writer = scope.start_el("CreatedBefore").finish();
inner_writer.data(
var_150
.fmt(aws_smithy_types::date_time::Format::DateTime)?
.as_ref(),
);
}
if let Some(var_151) = &input.object_replication_statuses {
let mut inner_writer = scope.start_el("ObjectReplicationStatuses").finish();
for list_item_152 in var_151 {
{
let mut inner_writer = inner_writer.start_el("member").finish();
inner_writer.data(list_item_152.as_str());
}
}
}
scope.finish();
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for ReplicationStatus
impl AsRef<str> for ReplicationStatus
source§impl Clone for ReplicationStatus
impl Clone for ReplicationStatus
source§fn clone(&self) -> ReplicationStatus
fn clone(&self) -> ReplicationStatus
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ReplicationStatus
impl Debug for ReplicationStatus
source§impl From<&str> for ReplicationStatus
impl From<&str> for ReplicationStatus
source§impl FromStr for ReplicationStatus
impl FromStr for ReplicationStatus
source§impl Hash for ReplicationStatus
impl Hash for ReplicationStatus
source§impl Ord for ReplicationStatus
impl Ord for ReplicationStatus
source§fn cmp(&self, other: &ReplicationStatus) -> Ordering
fn cmp(&self, other: &ReplicationStatus) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<ReplicationStatus> for ReplicationStatus
impl PartialEq<ReplicationStatus> for ReplicationStatus
source§fn eq(&self, other: &ReplicationStatus) -> bool
fn eq(&self, other: &ReplicationStatus) -> bool
source§impl PartialOrd<ReplicationStatus> for ReplicationStatus
impl PartialOrd<ReplicationStatus> for ReplicationStatus
source§fn partial_cmp(&self, other: &ReplicationStatus) -> Option<Ordering>
fn partial_cmp(&self, other: &ReplicationStatus) -> 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 ReplicationStatus
impl StructuralEq for ReplicationStatus
impl StructuralPartialEq for ReplicationStatus
Auto Trait Implementations§
impl RefUnwindSafe for ReplicationStatus
impl Send for ReplicationStatus
impl Sync for ReplicationStatus
impl Unpin for ReplicationStatus
impl UnwindSafe for ReplicationStatus
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.