Enum aws_sdk_iot::model::Protocol
source · #[non_exhaustive]
pub enum Protocol {
Http,
Mqtt,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against Protocol
, 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 protocol = unimplemented!();
match protocol {
Protocol::Http => { /* ... */ },
Protocol::Mqtt => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when protocol
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant Protocol::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
Protocol::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 Protocol::NewFeature
is defined.
Specifically, when protocol
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on Protocol::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
Http
Mqtt
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl Protocol
impl Protocol
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
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721
pub fn serialize_structure_crate_input_create_ota_update_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::CreateOtaUpdateInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_150) = &input.additional_parameters {
#[allow(unused_mut)]
let mut object_151 = object.key("additionalParameters").start_object();
for (key_152, value_153) in var_150 {
{
object_151.key(key_152.as_str()).string(value_153.as_str());
}
}
object_151.finish();
}
if let Some(var_154) = &input.aws_job_abort_config {
#[allow(unused_mut)]
let mut object_155 = object.key("awsJobAbortConfig").start_object();
crate::json_ser::serialize_structure_crate_model_aws_job_abort_config(
&mut object_155,
var_154,
)?;
object_155.finish();
}
if let Some(var_156) = &input.aws_job_executions_rollout_config {
#[allow(unused_mut)]
let mut object_157 = object.key("awsJobExecutionsRolloutConfig").start_object();
crate::json_ser::serialize_structure_crate_model_aws_job_executions_rollout_config(
&mut object_157,
var_156,
)?;
object_157.finish();
}
if let Some(var_158) = &input.aws_job_presigned_url_config {
#[allow(unused_mut)]
let mut object_159 = object.key("awsJobPresignedUrlConfig").start_object();
crate::json_ser::serialize_structure_crate_model_aws_job_presigned_url_config(
&mut object_159,
var_158,
)?;
object_159.finish();
}
if let Some(var_160) = &input.aws_job_timeout_config {
#[allow(unused_mut)]
let mut object_161 = object.key("awsJobTimeoutConfig").start_object();
crate::json_ser::serialize_structure_crate_model_aws_job_timeout_config(
&mut object_161,
var_160,
)?;
object_161.finish();
}
if let Some(var_162) = &input.description {
object.key("description").string(var_162.as_str());
}
if let Some(var_163) = &input.files {
let mut array_164 = object.key("files").start_array();
for item_165 in var_163 {
{
#[allow(unused_mut)]
let mut object_166 = array_164.value().start_object();
crate::json_ser::serialize_structure_crate_model_ota_update_file(
&mut object_166,
item_165,
)?;
object_166.finish();
}
}
array_164.finish();
}
if let Some(var_167) = &input.protocols {
let mut array_168 = object.key("protocols").start_array();
for item_169 in var_167 {
{
array_168.value().string(item_169.as_str());
}
}
array_168.finish();
}
if let Some(var_170) = &input.role_arn {
object.key("roleArn").string(var_170.as_str());
}
if let Some(var_171) = &input.tags {
let mut array_172 = object.key("tags").start_array();
for item_173 in var_171 {
{
#[allow(unused_mut)]
let mut object_174 = array_172.value().start_object();
crate::json_ser::serialize_structure_crate_model_tag(&mut object_174, item_173)?;
object_174.finish();
}
}
array_172.finish();
}
if let Some(var_175) = &input.target_selection {
object.key("targetSelection").string(var_175.as_str());
}
if let Some(var_176) = &input.targets {
let mut array_177 = object.key("targets").start_array();
for item_178 in var_176 {
{
array_177.value().string(item_178.as_str());
}
}
array_177.finish();
}
Ok(())
}
Trait Implementations§
source§impl Ord for Protocol
impl Ord for Protocol
source§impl PartialOrd<Protocol> for Protocol
impl PartialOrd<Protocol> for Protocol
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 Protocol
impl StructuralEq for Protocol
impl StructuralPartialEq for Protocol
Auto Trait Implementations§
impl RefUnwindSafe for Protocol
impl Send for Protocol
impl Sync for Protocol
impl Unpin for Protocol
impl UnwindSafe for Protocol
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.