Enum aws_sdk_iot::model::CertificateStatus
source · #[non_exhaustive]
pub enum CertificateStatus {
Active,
Inactive,
PendingActivation,
PendingTransfer,
RegisterInactive,
Revoked,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against CertificateStatus
, 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 certificatestatus = unimplemented!();
match certificatestatus {
CertificateStatus::Active => { /* ... */ },
CertificateStatus::Inactive => { /* ... */ },
CertificateStatus::PendingActivation => { /* ... */ },
CertificateStatus::PendingTransfer => { /* ... */ },
CertificateStatus::RegisterInactive => { /* ... */ },
CertificateStatus::Revoked => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when certificatestatus
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant CertificateStatus::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
CertificateStatus::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 CertificateStatus::NewFeature
is defined.
Specifically, when certificatestatus
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on CertificateStatus::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
Active
Inactive
PendingActivation
PendingTransfer
RegisterInactive
Revoked
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl CertificateStatus
impl CertificateStatus
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
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
pub fn serialize_structure_crate_input_register_certificate_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::RegisterCertificateInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_317) = &input.ca_certificate_pem {
object.key("caCertificatePem").string(var_317.as_str());
}
if let Some(var_318) = &input.certificate_pem {
object.key("certificatePem").string(var_318.as_str());
}
if let Some(var_319) = &input.status {
object.key("status").string(var_319.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_register_certificate_without_ca_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::RegisterCertificateWithoutCaInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_320) = &input.certificate_pem {
object.key("certificatePem").string(var_320.as_str());
}
if let Some(var_321) = &input.status {
object.key("status").string(var_321.as_str());
}
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for CertificateStatus
impl AsRef<str> for CertificateStatus
source§impl Clone for CertificateStatus
impl Clone for CertificateStatus
source§fn clone(&self) -> CertificateStatus
fn clone(&self) -> CertificateStatus
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for CertificateStatus
impl Debug for CertificateStatus
source§impl From<&str> for CertificateStatus
impl From<&str> for CertificateStatus
source§impl FromStr for CertificateStatus
impl FromStr for CertificateStatus
source§impl Hash for CertificateStatus
impl Hash for CertificateStatus
source§impl Ord for CertificateStatus
impl Ord for CertificateStatus
source§fn cmp(&self, other: &CertificateStatus) -> Ordering
fn cmp(&self, other: &CertificateStatus) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<CertificateStatus> for CertificateStatus
impl PartialEq<CertificateStatus> for CertificateStatus
source§fn eq(&self, other: &CertificateStatus) -> bool
fn eq(&self, other: &CertificateStatus) -> bool
source§impl PartialOrd<CertificateStatus> for CertificateStatus
impl PartialOrd<CertificateStatus> for CertificateStatus
source§fn partial_cmp(&self, other: &CertificateStatus) -> Option<Ordering>
fn partial_cmp(&self, other: &CertificateStatus) -> 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 CertificateStatus
impl StructuralEq for CertificateStatus
impl StructuralPartialEq for CertificateStatus
Auto Trait Implementations§
impl RefUnwindSafe for CertificateStatus
impl Send for CertificateStatus
impl Sync for CertificateStatus
impl Unpin for CertificateStatus
impl UnwindSafe for CertificateStatus
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.