#[non_exhaustive]
pub enum RegistrationStatus {
Complete,
Failed,
InProgress,
Unknown(UnknownVariantValue),
}Expand description
When writing a match expression against RegistrationStatus, 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 registrationstatus = unimplemented!();
match registrationstatus {
RegistrationStatus::Complete => { /* ... */ },
RegistrationStatus::Failed => { /* ... */ },
RegistrationStatus::InProgress => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when registrationstatus represents
NewFeature, the execution path will lead to the second last match arm,
even though the enum does not contain a variant RegistrationStatus::NewFeature
in the current version of SDK. The reason is that the variable other,
created by the @ operator, is bound to
RegistrationStatus::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 RegistrationStatus::NewFeature is defined.
Specifically, when registrationstatus represents NewFeature,
the execution path will hit the second last match arm as before by virtue of
calling as_str on RegistrationStatus::NewFeature also yielding "NewFeature".
Explicitly matching on the Unknown variant should
be avoided for two reasons:
- The inner data
UnknownVariantValueis 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
Complete
Failed
InProgress
Unknown(UnknownVariantValue)
Unknown contains new variants that have been added since this code was generated.
Implementations§
source§impl RegistrationStatus
impl RegistrationStatus
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
1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737
pub fn serialize_operation_crate_operation_list_type_registrations(
input: &crate::input::ListTypeRegistrationsInput,
) -> Result<aws_smithy_http::body::SdkBody, aws_smithy_http::operation::error::SerializationError> {
let mut out = String::new();
#[allow(unused_mut)]
let mut writer =
aws_smithy_query::QueryWriter::new(&mut out, "ListTypeRegistrations", "2010-05-15");
#[allow(unused_mut)]
let mut scope_479 = writer.prefix("Type");
if let Some(var_480) = &input.r#type {
scope_479.string(var_480.as_str());
}
#[allow(unused_mut)]
let mut scope_481 = writer.prefix("TypeName");
if let Some(var_482) = &input.type_name {
scope_481.string(var_482);
}
#[allow(unused_mut)]
let mut scope_483 = writer.prefix("TypeArn");
if let Some(var_484) = &input.type_arn {
scope_483.string(var_484);
}
#[allow(unused_mut)]
let mut scope_485 = writer.prefix("RegistrationStatusFilter");
if let Some(var_486) = &input.registration_status_filter {
scope_485.string(var_486.as_str());
}
#[allow(unused_mut)]
let mut scope_487 = writer.prefix("MaxResults");
if let Some(var_488) = &input.max_results {
scope_487.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_488).into()),
);
}
#[allow(unused_mut)]
let mut scope_489 = writer.prefix("NextToken");
if let Some(var_490) = &input.next_token {
scope_489.string(var_490);
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}Trait Implementations§
source§impl AsRef<str> for RegistrationStatus
impl AsRef<str> for RegistrationStatus
source§impl Clone for RegistrationStatus
impl Clone for RegistrationStatus
source§fn clone(&self) -> RegistrationStatus
fn clone(&self) -> RegistrationStatus
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for RegistrationStatus
impl Debug for RegistrationStatus
source§impl From<&str> for RegistrationStatus
impl From<&str> for RegistrationStatus
source§impl FromStr for RegistrationStatus
impl FromStr for RegistrationStatus
source§impl Hash for RegistrationStatus
impl Hash for RegistrationStatus
source§impl Ord for RegistrationStatus
impl Ord for RegistrationStatus
source§fn cmp(&self, other: &RegistrationStatus) -> Ordering
fn cmp(&self, other: &RegistrationStatus) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<RegistrationStatus> for RegistrationStatus
impl PartialEq<RegistrationStatus> for RegistrationStatus
source§fn eq(&self, other: &RegistrationStatus) -> bool
fn eq(&self, other: &RegistrationStatus) -> bool
source§impl PartialOrd<RegistrationStatus> for RegistrationStatus
impl PartialOrd<RegistrationStatus> for RegistrationStatus
source§fn partial_cmp(&self, other: &RegistrationStatus) -> Option<Ordering>
fn partial_cmp(&self, other: &RegistrationStatus) -> 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 RegistrationStatus
impl StructuralEq for RegistrationStatus
impl StructuralPartialEq for RegistrationStatus
Auto Trait Implementations§
impl RefUnwindSafe for RegistrationStatus
impl Send for RegistrationStatus
impl Sync for RegistrationStatus
impl Unpin for RegistrationStatus
impl UnwindSafe for RegistrationStatus
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.