Enum aws_sdk_iot::model::ThingIndexingMode
source · #[non_exhaustive]
pub enum ThingIndexingMode {
Off,
Registry,
RegistryAndShadow,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against ThingIndexingMode
, 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 thingindexingmode = unimplemented!();
match thingindexingmode {
ThingIndexingMode::Off => { /* ... */ },
ThingIndexingMode::Registry => { /* ... */ },
ThingIndexingMode::RegistryAndShadow => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when thingindexingmode
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant ThingIndexingMode::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
ThingIndexingMode::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 ThingIndexingMode::NewFeature
is defined.
Specifically, when thingindexingmode
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on ThingIndexingMode::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
Registry
RegistryAndShadow
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl ThingIndexingMode
impl ThingIndexingMode
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 ThingIndexingMode
impl AsRef<str> for ThingIndexingMode
source§impl Clone for ThingIndexingMode
impl Clone for ThingIndexingMode
source§fn clone(&self) -> ThingIndexingMode
fn clone(&self) -> ThingIndexingMode
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ThingIndexingMode
impl Debug for ThingIndexingMode
source§impl From<&str> for ThingIndexingMode
impl From<&str> for ThingIndexingMode
source§impl FromStr for ThingIndexingMode
impl FromStr for ThingIndexingMode
source§impl Hash for ThingIndexingMode
impl Hash for ThingIndexingMode
source§impl Ord for ThingIndexingMode
impl Ord for ThingIndexingMode
source§fn cmp(&self, other: &ThingIndexingMode) -> Ordering
fn cmp(&self, other: &ThingIndexingMode) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<ThingIndexingMode> for ThingIndexingMode
impl PartialEq<ThingIndexingMode> for ThingIndexingMode
source§fn eq(&self, other: &ThingIndexingMode) -> bool
fn eq(&self, other: &ThingIndexingMode) -> bool
source§impl PartialOrd<ThingIndexingMode> for ThingIndexingMode
impl PartialOrd<ThingIndexingMode> for ThingIndexingMode
source§fn partial_cmp(&self, other: &ThingIndexingMode) -> Option<Ordering>
fn partial_cmp(&self, other: &ThingIndexingMode) -> 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 ThingIndexingMode
impl StructuralEq for ThingIndexingMode
impl StructuralPartialEq for ThingIndexingMode
Auto Trait Implementations§
impl RefUnwindSafe for ThingIndexingMode
impl Send for ThingIndexingMode
impl Sync for ThingIndexingMode
impl Unpin for ThingIndexingMode
impl UnwindSafe for ThingIndexingMode
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.