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