aws_sdk_mediaconvert/types/_teletext_page_type.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// When writing a match expression against `TeletextPageType`, 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 teletextpagetype = unimplemented!();
14/// match teletextpagetype {
15/// TeletextPageType::PageTypeAddlInfo => { /* ... */ },
16/// TeletextPageType::PageTypeHearingImpairedSubtitle => { /* ... */ },
17/// TeletextPageType::PageTypeInitial => { /* ... */ },
18/// TeletextPageType::PageTypeProgramSchedule => { /* ... */ },
19/// TeletextPageType::PageTypeSubtitle => { /* ... */ },
20/// other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
21/// _ => { /* ... */ },
22/// }
23/// ```
24/// The above code demonstrates that when `teletextpagetype` represents
25/// `NewFeature`, the execution path will lead to the second last match arm,
26/// even though the enum does not contain a variant `TeletextPageType::NewFeature`
27/// in the current version of SDK. The reason is that the variable `other`,
28/// created by the `@` operator, is bound to
29/// `TeletextPageType::Unknown(UnknownVariantValue("NewFeature".to_owned()))`
30/// and calling `as_str` on it yields `"NewFeature"`.
31/// This match expression is forward-compatible when executed with a newer
32/// version of SDK where the variant `TeletextPageType::NewFeature` is defined.
33/// Specifically, when `teletextpagetype` represents `NewFeature`,
34/// the execution path will hit the second last match arm as before by virtue of
35/// calling `as_str` on `TeletextPageType::NewFeature` also yielding `"NewFeature"`.
36///
37/// Explicitly matching on the `Unknown` variant should
38/// be avoided for two reasons:
39/// - The inner data `UnknownVariantValue` is opaque, and no further information can be extracted.
40/// - It might inadvertently shadow other intended match arms.
41///
42/// A page type as defined in the standard ETSI EN 300 468, Table 94
43#[non_exhaustive]
44#[derive(
45 ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
46)]
47pub enum TeletextPageType {
48 #[allow(missing_docs)] // documentation missing in model
49 PageTypeAddlInfo,
50 #[allow(missing_docs)] // documentation missing in model
51 PageTypeHearingImpairedSubtitle,
52 #[allow(missing_docs)] // documentation missing in model
53 PageTypeInitial,
54 #[allow(missing_docs)] // documentation missing in model
55 PageTypeProgramSchedule,
56 #[allow(missing_docs)] // documentation missing in model
57 PageTypeSubtitle,
58 /// `Unknown` contains new variants that have been added since this code was generated.
59 #[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
60 Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
61}
62impl ::std::convert::From<&str> for TeletextPageType {
63 fn from(s: &str) -> Self {
64 match s {
65 "PAGE_TYPE_ADDL_INFO" => TeletextPageType::PageTypeAddlInfo,
66 "PAGE_TYPE_HEARING_IMPAIRED_SUBTITLE" => TeletextPageType::PageTypeHearingImpairedSubtitle,
67 "PAGE_TYPE_INITIAL" => TeletextPageType::PageTypeInitial,
68 "PAGE_TYPE_PROGRAM_SCHEDULE" => TeletextPageType::PageTypeProgramSchedule,
69 "PAGE_TYPE_SUBTITLE" => TeletextPageType::PageTypeSubtitle,
70 other => TeletextPageType::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
71 }
72 }
73}
74impl ::std::str::FromStr for TeletextPageType {
75 type Err = ::std::convert::Infallible;
76
77 fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
78 ::std::result::Result::Ok(TeletextPageType::from(s))
79 }
80}
81impl TeletextPageType {
82 /// Returns the `&str` value of the enum member.
83 pub fn as_str(&self) -> &str {
84 match self {
85 TeletextPageType::PageTypeAddlInfo => "PAGE_TYPE_ADDL_INFO",
86 TeletextPageType::PageTypeHearingImpairedSubtitle => "PAGE_TYPE_HEARING_IMPAIRED_SUBTITLE",
87 TeletextPageType::PageTypeInitial => "PAGE_TYPE_INITIAL",
88 TeletextPageType::PageTypeProgramSchedule => "PAGE_TYPE_PROGRAM_SCHEDULE",
89 TeletextPageType::PageTypeSubtitle => "PAGE_TYPE_SUBTITLE",
90 TeletextPageType::Unknown(value) => value.as_str(),
91 }
92 }
93 /// Returns all the `&str` representations of the enum members.
94 pub const fn values() -> &'static [&'static str] {
95 &[
96 "PAGE_TYPE_ADDL_INFO",
97 "PAGE_TYPE_HEARING_IMPAIRED_SUBTITLE",
98 "PAGE_TYPE_INITIAL",
99 "PAGE_TYPE_PROGRAM_SCHEDULE",
100 "PAGE_TYPE_SUBTITLE",
101 ]
102 }
103}
104impl ::std::convert::AsRef<str> for TeletextPageType {
105 fn as_ref(&self) -> &str {
106 self.as_str()
107 }
108}
109impl TeletextPageType {
110 /// Parses the enum value while disallowing unknown variants.
111 ///
112 /// Unknown variants will result in an error.
113 pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
114 match Self::from(value) {
115 #[allow(deprecated)]
116 Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
117 known => Ok(known),
118 }
119 }
120}
121impl ::std::fmt::Display for TeletextPageType {
122 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
123 match self {
124 TeletextPageType::PageTypeAddlInfo => write!(f, "PAGE_TYPE_ADDL_INFO"),
125 TeletextPageType::PageTypeHearingImpairedSubtitle => write!(f, "PAGE_TYPE_HEARING_IMPAIRED_SUBTITLE"),
126 TeletextPageType::PageTypeInitial => write!(f, "PAGE_TYPE_INITIAL"),
127 TeletextPageType::PageTypeProgramSchedule => write!(f, "PAGE_TYPE_PROGRAM_SCHEDULE"),
128 TeletextPageType::PageTypeSubtitle => write!(f, "PAGE_TYPE_SUBTITLE"),
129 TeletextPageType::Unknown(value) => write!(f, "{value}"),
130 }
131 }
132}