Skip to main content

aws_sdk_mediaconvert/types/
_color_space.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// When writing a match expression against `ColorSpace`, 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 colorspace = unimplemented!();
14/// match colorspace {
15///     ColorSpace::Follow => { /* ... */ },
16///     ColorSpace::Hdr10 => { /* ... */ },
17///     ColorSpace::Hlg2020 => { /* ... */ },
18///     ColorSpace::P3D65Hdr => { /* ... */ },
19///     ColorSpace::P3D65Sdr => { /* ... */ },
20///     ColorSpace::P3Dci => { /* ... */ },
21///     ColorSpace::Rec601 => { /* ... */ },
22///     ColorSpace::Rec709 => { /* ... */ },
23///     other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
24///     _ => { /* ... */ },
25/// }
26/// ```
27/// The above code demonstrates that when `colorspace` represents
28/// `NewFeature`, the execution path will lead to the second last match arm,
29/// even though the enum does not contain a variant `ColorSpace::NewFeature`
30/// in the current version of SDK. The reason is that the variable `other`,
31/// created by the `@` operator, is bound to
32/// `ColorSpace::Unknown(UnknownVariantValue("NewFeature".to_owned()))`
33/// and calling `as_str` on it yields `"NewFeature"`.
34/// This match expression is forward-compatible when executed with a newer
35/// version of SDK where the variant `ColorSpace::NewFeature` is defined.
36/// Specifically, when `colorspace` represents `NewFeature`,
37/// the execution path will hit the second last match arm as before by virtue of
38/// calling `as_str` on `ColorSpace::NewFeature` also yielding `"NewFeature"`.
39///
40/// Explicitly matching on the `Unknown` variant should
41/// be avoided for two reasons:
42/// - The inner data `UnknownVariantValue` is opaque, and no further information can be extracted.
43/// - It might inadvertently shadow other intended match arms.
44///
45/// If your input video has accurate color space metadata, or if you don't know about color space: Keep the default value, Follow. MediaConvert will automatically detect your input color space. If your input video has metadata indicating the wrong color space, or has missing metadata: Specify the accurate color space here. If your input video is HDR 10 and the SMPTE ST 2086 Mastering Display Color Volume static metadata isn't present in your video stream, or if that metadata is present but not accurate: Choose Force HDR 10. Specify correct values in the input HDR 10 metadata settings. For more information about HDR jobs, see https://docs.aws.amazon.com/console/mediaconvert/hdr. When you specify an input color space, MediaConvert uses the following color space metadata, which includes color primaries, transfer characteristics, and matrix coefficients:
46/// * HDR 10: BT.2020, PQ, BT.2020 non-constant
47/// * HLG 2020: BT.2020, HLG, BT.2020 non-constant
48/// * P3DCI (Theater): DCIP3, SMPTE 428M, BT.709
49/// * P3D65 (SDR): Display P3, sRGB, BT.709
50/// * P3D65 (HDR): Display P3, PQ, BT.709
51#[non_exhaustive]
52#[derive(
53    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
54)]
55pub enum ColorSpace {
56    #[allow(missing_docs)] // documentation missing in model
57    Follow,
58    #[allow(missing_docs)] // documentation missing in model
59    Hdr10,
60    #[allow(missing_docs)] // documentation missing in model
61    Hlg2020,
62    #[allow(missing_docs)] // documentation missing in model
63    P3D65Hdr,
64    #[allow(missing_docs)] // documentation missing in model
65    P3D65Sdr,
66    #[allow(missing_docs)] // documentation missing in model
67    P3Dci,
68    #[allow(missing_docs)] // documentation missing in model
69    Rec601,
70    #[allow(missing_docs)] // documentation missing in model
71    Rec709,
72    /// `Unknown` contains new variants that have been added since this code was generated.
73    #[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
74    Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
75}
76impl ::std::convert::From<&str> for ColorSpace {
77    fn from(s: &str) -> Self {
78        match s {
79            "FOLLOW" => ColorSpace::Follow,
80            "HDR10" => ColorSpace::Hdr10,
81            "HLG_2020" => ColorSpace::Hlg2020,
82            "P3D65_HDR" => ColorSpace::P3D65Hdr,
83            "P3D65_SDR" => ColorSpace::P3D65Sdr,
84            "P3DCI" => ColorSpace::P3Dci,
85            "REC_601" => ColorSpace::Rec601,
86            "REC_709" => ColorSpace::Rec709,
87            other => ColorSpace::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
88        }
89    }
90}
91impl ::std::str::FromStr for ColorSpace {
92    type Err = ::std::convert::Infallible;
93
94    fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
95        ::std::result::Result::Ok(ColorSpace::from(s))
96    }
97}
98impl ColorSpace {
99    /// Returns the `&str` value of the enum member.
100    pub fn as_str(&self) -> &str {
101        match self {
102            ColorSpace::Follow => "FOLLOW",
103            ColorSpace::Hdr10 => "HDR10",
104            ColorSpace::Hlg2020 => "HLG_2020",
105            ColorSpace::P3D65Hdr => "P3D65_HDR",
106            ColorSpace::P3D65Sdr => "P3D65_SDR",
107            ColorSpace::P3Dci => "P3DCI",
108            ColorSpace::Rec601 => "REC_601",
109            ColorSpace::Rec709 => "REC_709",
110            ColorSpace::Unknown(value) => value.as_str(),
111        }
112    }
113    /// Returns all the `&str` representations of the enum members.
114    pub const fn values() -> &'static [&'static str] {
115        &["FOLLOW", "HDR10", "HLG_2020", "P3D65_HDR", "P3D65_SDR", "P3DCI", "REC_601", "REC_709"]
116    }
117}
118impl ::std::convert::AsRef<str> for ColorSpace {
119    fn as_ref(&self) -> &str {
120        self.as_str()
121    }
122}
123impl ColorSpace {
124    /// Parses the enum value while disallowing unknown variants.
125    ///
126    /// Unknown variants will result in an error.
127    pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
128        match Self::from(value) {
129            #[allow(deprecated)]
130            Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
131            known => Ok(known),
132        }
133    }
134}
135impl ::std::fmt::Display for ColorSpace {
136    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
137        match self {
138            ColorSpace::Follow => write!(f, "FOLLOW"),
139            ColorSpace::Hdr10 => write!(f, "HDR10"),
140            ColorSpace::Hlg2020 => write!(f, "HLG_2020"),
141            ColorSpace::P3D65Hdr => write!(f, "P3D65_HDR"),
142            ColorSpace::P3D65Sdr => write!(f, "P3D65_SDR"),
143            ColorSpace::P3Dci => write!(f, "P3DCI"),
144            ColorSpace::Rec601 => write!(f, "REC_601"),
145            ColorSpace::Rec709 => write!(f, "REC_709"),
146            ColorSpace::Unknown(value) => write!(f, "{value}"),
147        }
148    }
149}