#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Http

§

Mqtt

§

Unknown(UnknownVariantValue)

Unknown contains new variants that have been added since this code was generated.

Implementations§

Returns the &str value of the enum member.

Examples found in repository?
src/model.rs (line 23983)
23982
23983
23984
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/json_ser.rs (line 688)
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(())
}

Returns all the &str values of the enum members.

Trait Implementations§

Converts this type into a shared reference of the (usually inferred) input type.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more