#[non_exhaustive]
pub enum MediaFormat {
    Amr,
    Flac,
    Mp3,
    Mp4,
    Ogg,
    Wav,
    Webm,
    Unknown(UnknownVariantValue),
}
Expand description

When writing a match expression against MediaFormat, 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 mediaformat = unimplemented!();
match mediaformat {
    MediaFormat::Amr => { /* ... */ },
    MediaFormat::Flac => { /* ... */ },
    MediaFormat::Mp3 => { /* ... */ },
    MediaFormat::Mp4 => { /* ... */ },
    MediaFormat::Ogg => { /* ... */ },
    MediaFormat::Wav => { /* ... */ },
    MediaFormat::Webm => { /* ... */ },
    other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
    _ => { /* ... */ },
}

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

Amr

§

Flac

§

Mp3

§

Mp4

§

Ogg

§

Wav

§

Webm

§

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 4097)
4096
4097
4098
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/json_ser.rs (line 573)
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
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
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
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(())
}

pub fn serialize_structure_crate_input_start_transcription_job_input(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::input::StartTranscriptionJobInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_122) = &input.transcription_job_name {
        object.key("TranscriptionJobName").string(var_122.as_str());
    }
    if let Some(var_123) = &input.language_code {
        object.key("LanguageCode").string(var_123.as_str());
    }
    if let Some(var_124) = &input.media_sample_rate_hertz {
        object.key("MediaSampleRateHertz").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_124).into()),
        );
    }
    if let Some(var_125) = &input.media_format {
        object.key("MediaFormat").string(var_125.as_str());
    }
    if let Some(var_126) = &input.media {
        #[allow(unused_mut)]
        let mut object_127 = object.key("Media").start_object();
        crate::json_ser::serialize_structure_crate_model_media(&mut object_127, var_126)?;
        object_127.finish();
    }
    if let Some(var_128) = &input.output_bucket_name {
        object.key("OutputBucketName").string(var_128.as_str());
    }
    if let Some(var_129) = &input.output_key {
        object.key("OutputKey").string(var_129.as_str());
    }
    if let Some(var_130) = &input.output_encryption_kms_key_id {
        object
            .key("OutputEncryptionKMSKeyId")
            .string(var_130.as_str());
    }
    if let Some(var_131) = &input.kms_encryption_context {
        #[allow(unused_mut)]
        let mut object_132 = object.key("KMSEncryptionContext").start_object();
        for (key_133, value_134) in var_131 {
            {
                object_132.key(key_133.as_str()).string(value_134.as_str());
            }
        }
        object_132.finish();
    }
    if let Some(var_135) = &input.settings {
        #[allow(unused_mut)]
        let mut object_136 = object.key("Settings").start_object();
        crate::json_ser::serialize_structure_crate_model_settings(&mut object_136, var_135)?;
        object_136.finish();
    }
    if let Some(var_137) = &input.model_settings {
        #[allow(unused_mut)]
        let mut object_138 = object.key("ModelSettings").start_object();
        crate::json_ser::serialize_structure_crate_model_model_settings(&mut object_138, var_137)?;
        object_138.finish();
    }
    if let Some(var_139) = &input.job_execution_settings {
        #[allow(unused_mut)]
        let mut object_140 = object.key("JobExecutionSettings").start_object();
        crate::json_ser::serialize_structure_crate_model_job_execution_settings(
            &mut object_140,
            var_139,
        )?;
        object_140.finish();
    }
    if let Some(var_141) = &input.content_redaction {
        #[allow(unused_mut)]
        let mut object_142 = object.key("ContentRedaction").start_object();
        crate::json_ser::serialize_structure_crate_model_content_redaction(
            &mut object_142,
            var_141,
        )?;
        object_142.finish();
    }
    if let Some(var_143) = &input.identify_language {
        object.key("IdentifyLanguage").boolean(*var_143);
    }
    if let Some(var_144) = &input.identify_multiple_languages {
        object.key("IdentifyMultipleLanguages").boolean(*var_144);
    }
    if let Some(var_145) = &input.language_options {
        let mut array_146 = object.key("LanguageOptions").start_array();
        for item_147 in var_145 {
            {
                array_146.value().string(item_147.as_str());
            }
        }
        array_146.finish();
    }
    if let Some(var_148) = &input.subtitles {
        #[allow(unused_mut)]
        let mut object_149 = object.key("Subtitles").start_object();
        crate::json_ser::serialize_structure_crate_model_subtitles(&mut object_149, var_148)?;
        object_149.finish();
    }
    if let Some(var_150) = &input.tags {
        let mut array_151 = object.key("Tags").start_array();
        for item_152 in var_150 {
            {
                #[allow(unused_mut)]
                let mut object_153 = array_151.value().start_object();
                crate::json_ser::serialize_structure_crate_model_tag(&mut object_153, item_152)?;
                object_153.finish();
            }
        }
        array_151.finish();
    }
    if let Some(var_154) = &input.language_id_settings {
        #[allow(unused_mut)]
        let mut object_155 = object.key("LanguageIdSettings").start_object();
        for (key_156, value_157) in var_154 {
            {
                #[allow(unused_mut)]
                let mut object_158 = object_155.key(key_156.as_str()).start_object();
                crate::json_ser::serialize_structure_crate_model_language_id_settings(
                    &mut object_158,
                    value_157,
                )?;
                object_158.finish();
            }
        }
        object_155.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