aws_sdk_s3control/types/
_multi_region_access_point_status.rs

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