Enum aws_sdk_iot::model::TemplateType
source · #[non_exhaustive]
pub enum TemplateType {
FleetProvisioning,
Jitp,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against TemplateType
, 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 templatetype = unimplemented!();
match templatetype {
TemplateType::FleetProvisioning => { /* ... */ },
TemplateType::Jitp => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when templatetype
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant TemplateType::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
TemplateType::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 TemplateType::NewFeature
is defined.
Specifically, when templatetype
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on TemplateType::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
FleetProvisioning
Jitp
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl TemplateType
impl TemplateType
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
755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799
pub fn serialize_structure_crate_input_create_provisioning_template_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::CreateProvisioningTemplateInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_185) = &input.description {
object.key("description").string(var_185.as_str());
}
if input.enabled {
object.key("enabled").boolean(input.enabled);
}
if let Some(var_186) = &input.pre_provisioning_hook {
#[allow(unused_mut)]
let mut object_187 = object.key("preProvisioningHook").start_object();
crate::json_ser::serialize_structure_crate_model_provisioning_hook(
&mut object_187,
var_186,
)?;
object_187.finish();
}
if let Some(var_188) = &input.provisioning_role_arn {
object.key("provisioningRoleArn").string(var_188.as_str());
}
if let Some(var_189) = &input.tags {
let mut array_190 = object.key("tags").start_array();
for item_191 in var_189 {
{
#[allow(unused_mut)]
let mut object_192 = array_190.value().start_object();
crate::json_ser::serialize_structure_crate_model_tag(&mut object_192, item_191)?;
object_192.finish();
}
}
array_190.finish();
}
if let Some(var_193) = &input.template_body {
object.key("templateBody").string(var_193.as_str());
}
if let Some(var_194) = &input.template_name {
object.key("templateName").string(var_194.as_str());
}
if let Some(var_195) = &input.r#type {
object.key("type").string(var_195.as_str());
}
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for TemplateType
impl AsRef<str> for TemplateType
source§impl Clone for TemplateType
impl Clone for TemplateType
source§fn clone(&self) -> TemplateType
fn clone(&self) -> TemplateType
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TemplateType
impl Debug for TemplateType
source§impl From<&str> for TemplateType
impl From<&str> for TemplateType
source§impl FromStr for TemplateType
impl FromStr for TemplateType
source§impl Hash for TemplateType
impl Hash for TemplateType
source§impl Ord for TemplateType
impl Ord for TemplateType
source§fn cmp(&self, other: &TemplateType) -> Ordering
fn cmp(&self, other: &TemplateType) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<TemplateType> for TemplateType
impl PartialEq<TemplateType> for TemplateType
source§fn eq(&self, other: &TemplateType) -> bool
fn eq(&self, other: &TemplateType) -> bool
source§impl PartialOrd<TemplateType> for TemplateType
impl PartialOrd<TemplateType> for TemplateType
source§fn partial_cmp(&self, other: &TemplateType) -> Option<Ordering>
fn partial_cmp(&self, other: &TemplateType) -> 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 TemplateType
impl StructuralEq for TemplateType
impl StructuralPartialEq for TemplateType
Auto Trait Implementations§
impl RefUnwindSafe for TemplateType
impl Send for TemplateType
impl Sync for TemplateType
impl Unpin for TemplateType
impl UnwindSafe for TemplateType
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.