#[non_exhaustive]
pub enum Specialty {
    Primarycare,
    Unknown(UnknownVariantValue),
}
Expand description

When writing a match expression against Specialty, 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 specialty = unimplemented!();
match specialty {
    Specialty::Primarycare => { /* ... */ },
    other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
    _ => { /* ... */ },
}

The above code demonstrates that when specialty represents NewFeature, the execution path will lead to the second last match arm, even though the enum does not contain a variant Specialty::NewFeature in the current version of SDK. The reason is that the variable other, created by the @ operator, is bound to Specialty::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 Specialty::NewFeature is defined. Specifically, when specialty represents NewFeature, the execution path will hit the second last match arm as before by virtue of calling as_str on Specialty::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.
§

Primarycare

§

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 4903)
4902
4903
4904
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/json_ser.rs (line 617)
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
pub fn serialize_structure_crate_input_start_medical_transcription_job_input(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::input::StartMedicalTranscriptionJobInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_100) = &input.medical_transcription_job_name {
        object
            .key("MedicalTranscriptionJobName")
            .string(var_100.as_str());
    }
    if let Some(var_101) = &input.language_code {
        object.key("LanguageCode").string(var_101.as_str());
    }
    if let Some(var_102) = &input.media_sample_rate_hertz {
        object.key("MediaSampleRateHertz").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_102).into()),
        );
    }
    if let Some(var_103) = &input.media_format {
        object.key("MediaFormat").string(var_103.as_str());
    }
    if let Some(var_104) = &input.media {
        #[allow(unused_mut)]
        let mut object_105 = object.key("Media").start_object();
        crate::json_ser::serialize_structure_crate_model_media(&mut object_105, var_104)?;
        object_105.finish();
    }
    if let Some(var_106) = &input.output_bucket_name {
        object.key("OutputBucketName").string(var_106.as_str());
    }
    if let Some(var_107) = &input.output_key {
        object.key("OutputKey").string(var_107.as_str());
    }
    if let Some(var_108) = &input.output_encryption_kms_key_id {
        object
            .key("OutputEncryptionKMSKeyId")
            .string(var_108.as_str());
    }
    if let Some(var_109) = &input.kms_encryption_context {
        #[allow(unused_mut)]
        let mut object_110 = object.key("KMSEncryptionContext").start_object();
        for (key_111, value_112) in var_109 {
            {
                object_110.key(key_111.as_str()).string(value_112.as_str());
            }
        }
        object_110.finish();
    }
    if let Some(var_113) = &input.settings {
        #[allow(unused_mut)]
        let mut object_114 = object.key("Settings").start_object();
        crate::json_ser::serialize_structure_crate_model_medical_transcription_setting(
            &mut object_114,
            var_113,
        )?;
        object_114.finish();
    }
    if let Some(var_115) = &input.content_identification_type {
        object
            .key("ContentIdentificationType")
            .string(var_115.as_str());
    }
    if let Some(var_116) = &input.specialty {
        object.key("Specialty").string(var_116.as_str());
    }
    if let Some(var_117) = &input.r#type {
        object.key("Type").string(var_117.as_str());
    }
    if let Some(var_118) = &input.tags {
        let mut array_119 = object.key("Tags").start_array();
        for item_120 in var_118 {
            {
                #[allow(unused_mut)]
                let mut object_121 = array_119.value().start_object();
                crate::json_ser::serialize_structure_crate_model_tag(&mut object_121, item_120)?;
                object_121.finish();
            }
        }
        array_119.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