aws_sdk_lambda/types/
_end_point_type.rs

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