#[non_exhaustive]
pub enum DeviceDefenderIndexingMode {
Off,
Violations,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against DeviceDefenderIndexingMode
, 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 devicedefenderindexingmode = unimplemented!();
match devicedefenderindexingmode {
DeviceDefenderIndexingMode::Off => { /* ... */ },
DeviceDefenderIndexingMode::Violations => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when devicedefenderindexingmode
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant DeviceDefenderIndexingMode::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
DeviceDefenderIndexingMode::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 DeviceDefenderIndexingMode::NewFeature
is defined.
Specifically, when devicedefenderindexingmode
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on DeviceDefenderIndexingMode::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
Off
Violations
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl DeviceDefenderIndexingMode
impl DeviceDefenderIndexingMode
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
3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347
pub fn serialize_structure_crate_model_thing_indexing_configuration(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::ThingIndexingConfiguration,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_680) = &input.thing_indexing_mode {
object.key("thingIndexingMode").string(var_680.as_str());
}
if let Some(var_681) = &input.thing_connectivity_indexing_mode {
object
.key("thingConnectivityIndexingMode")
.string(var_681.as_str());
}
if let Some(var_682) = &input.device_defender_indexing_mode {
object
.key("deviceDefenderIndexingMode")
.string(var_682.as_str());
}
if let Some(var_683) = &input.named_shadow_indexing_mode {
object
.key("namedShadowIndexingMode")
.string(var_683.as_str());
}
if let Some(var_684) = &input.managed_fields {
let mut array_685 = object.key("managedFields").start_array();
for item_686 in var_684 {
{
#[allow(unused_mut)]
let mut object_687 = array_685.value().start_object();
crate::json_ser::serialize_structure_crate_model_field(&mut object_687, item_686)?;
object_687.finish();
}
}
array_685.finish();
}
if let Some(var_688) = &input.custom_fields {
let mut array_689 = object.key("customFields").start_array();
for item_690 in var_688 {
{
#[allow(unused_mut)]
let mut object_691 = array_689.value().start_object();
crate::json_ser::serialize_structure_crate_model_field(&mut object_691, item_690)?;
object_691.finish();
}
}
array_689.finish();
}
if let Some(var_692) = &input.filter {
#[allow(unused_mut)]
let mut object_693 = object.key("filter").start_object();
crate::json_ser::serialize_structure_crate_model_indexing_filter(&mut object_693, var_692)?;
object_693.finish();
}
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for DeviceDefenderIndexingMode
impl AsRef<str> for DeviceDefenderIndexingMode
source§impl Clone for DeviceDefenderIndexingMode
impl Clone for DeviceDefenderIndexingMode
source§fn clone(&self) -> DeviceDefenderIndexingMode
fn clone(&self) -> DeviceDefenderIndexingMode
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for DeviceDefenderIndexingMode
impl Debug for DeviceDefenderIndexingMode
source§impl From<&str> for DeviceDefenderIndexingMode
impl From<&str> for DeviceDefenderIndexingMode
source§impl FromStr for DeviceDefenderIndexingMode
impl FromStr for DeviceDefenderIndexingMode
source§impl Hash for DeviceDefenderIndexingMode
impl Hash for DeviceDefenderIndexingMode
source§impl Ord for DeviceDefenderIndexingMode
impl Ord for DeviceDefenderIndexingMode
source§fn cmp(&self, other: &DeviceDefenderIndexingMode) -> Ordering
fn cmp(&self, other: &DeviceDefenderIndexingMode) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<DeviceDefenderIndexingMode> for DeviceDefenderIndexingMode
impl PartialEq<DeviceDefenderIndexingMode> for DeviceDefenderIndexingMode
source§fn eq(&self, other: &DeviceDefenderIndexingMode) -> bool
fn eq(&self, other: &DeviceDefenderIndexingMode) -> bool
source§impl PartialOrd<DeviceDefenderIndexingMode> for DeviceDefenderIndexingMode
impl PartialOrd<DeviceDefenderIndexingMode> for DeviceDefenderIndexingMode
source§fn partial_cmp(&self, other: &DeviceDefenderIndexingMode) -> Option<Ordering>
fn partial_cmp(&self, other: &DeviceDefenderIndexingMode) -> 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 DeviceDefenderIndexingMode
impl StructuralEq for DeviceDefenderIndexingMode
impl StructuralPartialEq for DeviceDefenderIndexingMode
Auto Trait Implementations§
impl RefUnwindSafe for DeviceDefenderIndexingMode
impl Send for DeviceDefenderIndexingMode
impl Sync for DeviceDefenderIndexingMode
impl Unpin for DeviceDefenderIndexingMode
impl UnwindSafe for DeviceDefenderIndexingMode
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.