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