aws_sdk_mediaconvert/types/
_h264_codec_profile.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// When writing a match expression against `H264CodecProfile`, it is important to ensure
4/// your code is forward-compatible. That is, if a match arm handles a case for a
5/// feature that is supported by the service but has not been represented as an enum
6/// variant in a current version of SDK, your code should continue to work when you
7/// upgrade SDK to a future version in which the enum does include a variant for that
8/// feature.
9///
10/// Here is an example of how you can make a match expression forward-compatible:
11///
12/// ```text
13/// # let h264codecprofile = unimplemented!();
14/// match h264codecprofile {
15///     H264CodecProfile::Baseline => { /* ... */ },
16///     H264CodecProfile::High => { /* ... */ },
17///     H264CodecProfile::High10Bit => { /* ... */ },
18///     H264CodecProfile::High422 => { /* ... */ },
19///     H264CodecProfile::High42210Bit => { /* ... */ },
20///     H264CodecProfile::Main => { /* ... */ },
21///     other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
22///     _ => { /* ... */ },
23/// }
24/// ```
25/// The above code demonstrates that when `h264codecprofile` represents
26/// `NewFeature`, the execution path will lead to the second last match arm,
27/// even though the enum does not contain a variant `H264CodecProfile::NewFeature`
28/// in the current version of SDK. The reason is that the variable `other`,
29/// created by the `@` operator, is bound to
30/// `H264CodecProfile::Unknown(UnknownVariantValue("NewFeature".to_owned()))`
31/// and calling `as_str` on it yields `"NewFeature"`.
32/// This match expression is forward-compatible when executed with a newer
33/// version of SDK where the variant `H264CodecProfile::NewFeature` is defined.
34/// Specifically, when `h264codecprofile` represents `NewFeature`,
35/// the execution path will hit the second last match arm as before by virtue of
36/// calling `as_str` on `H264CodecProfile::NewFeature` also yielding `"NewFeature"`.
37///
38/// Explicitly matching on the `Unknown` variant should
39/// be avoided for two reasons:
40/// - The inner data `UnknownVariantValue` is opaque, and no further information can be extracted.
41/// - It might inadvertently shadow other intended match arms.
42///
43/// H.264 Profile. High 4:2:2 and 10-bit profiles are only available with the AVC-I License.
44#[non_exhaustive]
45#[derive(
46    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
47)]
48pub enum H264CodecProfile {
49    #[allow(missing_docs)] // documentation missing in model
50    Baseline,
51    #[allow(missing_docs)] // documentation missing in model
52    High,
53    #[allow(missing_docs)] // documentation missing in model
54    High10Bit,
55    #[allow(missing_docs)] // documentation missing in model
56    High422,
57    #[allow(missing_docs)] // documentation missing in model
58    High42210Bit,
59    #[allow(missing_docs)] // documentation missing in model
60    Main,
61    /// `Unknown` contains new variants that have been added since this code was generated.
62    #[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
63    Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
64}
65impl ::std::convert::From<&str> for H264CodecProfile {
66    fn from(s: &str) -> Self {
67        match s {
68            "BASELINE" => H264CodecProfile::Baseline,
69            "HIGH" => H264CodecProfile::High,
70            "HIGH_10BIT" => H264CodecProfile::High10Bit,
71            "HIGH_422" => H264CodecProfile::High422,
72            "HIGH_422_10BIT" => H264CodecProfile::High42210Bit,
73            "MAIN" => H264CodecProfile::Main,
74            other => H264CodecProfile::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
75        }
76    }
77}
78impl ::std::str::FromStr for H264CodecProfile {
79    type Err = ::std::convert::Infallible;
80
81    fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
82        ::std::result::Result::Ok(H264CodecProfile::from(s))
83    }
84}
85impl H264CodecProfile {
86    /// Returns the `&str` value of the enum member.
87    pub fn as_str(&self) -> &str {
88        match self {
89            H264CodecProfile::Baseline => "BASELINE",
90            H264CodecProfile::High => "HIGH",
91            H264CodecProfile::High10Bit => "HIGH_10BIT",
92            H264CodecProfile::High422 => "HIGH_422",
93            H264CodecProfile::High42210Bit => "HIGH_422_10BIT",
94            H264CodecProfile::Main => "MAIN",
95            H264CodecProfile::Unknown(value) => value.as_str(),
96        }
97    }
98    /// Returns all the `&str` representations of the enum members.
99    pub const fn values() -> &'static [&'static str] {
100        &["BASELINE", "HIGH", "HIGH_10BIT", "HIGH_422", "HIGH_422_10BIT", "MAIN"]
101    }
102}
103impl ::std::convert::AsRef<str> for H264CodecProfile {
104    fn as_ref(&self) -> &str {
105        self.as_str()
106    }
107}
108impl H264CodecProfile {
109    /// Parses the enum value while disallowing unknown variants.
110    ///
111    /// Unknown variants will result in an error.
112    pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
113        match Self::from(value) {
114            #[allow(deprecated)]
115            Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
116            known => Ok(known),
117        }
118    }
119}
120impl ::std::fmt::Display for H264CodecProfile {
121    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
122        match self {
123            H264CodecProfile::Baseline => write!(f, "BASELINE"),
124            H264CodecProfile::High => write!(f, "HIGH"),
125            H264CodecProfile::High10Bit => write!(f, "HIGH_10BIT"),
126            H264CodecProfile::High422 => write!(f, "HIGH_422"),
127            H264CodecProfile::High42210Bit => write!(f, "HIGH_422_10BIT"),
128            H264CodecProfile::Main => write!(f, "MAIN"),
129            H264CodecProfile::Unknown(value) => write!(f, "{}", value),
130        }
131    }
132}