Enum aws_sdk_ssm::model::CommandFilterKey
source · #[non_exhaustive]
pub enum CommandFilterKey {
DocumentName,
ExecutionStage,
InvokedAfter,
InvokedBefore,
Status,
Unknown(UnknownVariantValue),
}Expand description
When writing a match expression against CommandFilterKey, 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 commandfilterkey = unimplemented!();
match commandfilterkey {
CommandFilterKey::DocumentName => { /* ... */ },
CommandFilterKey::ExecutionStage => { /* ... */ },
CommandFilterKey::InvokedAfter => { /* ... */ },
CommandFilterKey::InvokedBefore => { /* ... */ },
CommandFilterKey::Status => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when commandfilterkey represents
NewFeature, the execution path will lead to the second last match arm,
even though the enum does not contain a variant CommandFilterKey::NewFeature
in the current version of SDK. The reason is that the variable other,
created by the @ operator, is bound to
CommandFilterKey::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 CommandFilterKey::NewFeature is defined.
Specifically, when commandfilterkey represents NewFeature,
the execution path will hit the second last match arm as before by virtue of
calling as_str on CommandFilterKey::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
DocumentName
ExecutionStage
InvokedAfter
InvokedBefore
Status
Unknown(UnknownVariantValue)
Unknown contains new variants that have been added since this code was generated.
Implementations§
source§impl CommandFilterKey
impl CommandFilterKey
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
5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324
pub fn serialize_structure_crate_model_command_filter(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::CommandFilter,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_1178) = &input.key {
object.key("key").string(var_1178.as_str());
}
if let Some(var_1179) = &input.value {
object.key("value").string(var_1179.as_str());
}
Ok(())
}Trait Implementations§
source§impl AsRef<str> for CommandFilterKey
impl AsRef<str> for CommandFilterKey
source§impl Clone for CommandFilterKey
impl Clone for CommandFilterKey
source§fn clone(&self) -> CommandFilterKey
fn clone(&self) -> CommandFilterKey
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for CommandFilterKey
impl Debug for CommandFilterKey
source§impl From<&str> for CommandFilterKey
impl From<&str> for CommandFilterKey
source§impl FromStr for CommandFilterKey
impl FromStr for CommandFilterKey
source§impl Hash for CommandFilterKey
impl Hash for CommandFilterKey
source§impl Ord for CommandFilterKey
impl Ord for CommandFilterKey
source§fn cmp(&self, other: &CommandFilterKey) -> Ordering
fn cmp(&self, other: &CommandFilterKey) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<CommandFilterKey> for CommandFilterKey
impl PartialEq<CommandFilterKey> for CommandFilterKey
source§fn eq(&self, other: &CommandFilterKey) -> bool
fn eq(&self, other: &CommandFilterKey) -> bool
source§impl PartialOrd<CommandFilterKey> for CommandFilterKey
impl PartialOrd<CommandFilterKey> for CommandFilterKey
source§fn partial_cmp(&self, other: &CommandFilterKey) -> Option<Ordering>
fn partial_cmp(&self, other: &CommandFilterKey) -> 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 CommandFilterKey
impl StructuralEq for CommandFilterKey
impl StructuralPartialEq for CommandFilterKey
Auto Trait Implementations§
impl RefUnwindSafe for CommandFilterKey
impl Send for CommandFilterKey
impl Sync for CommandFilterKey
impl Unpin for CommandFilterKey
impl UnwindSafe for CommandFilterKey
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.