Skip to main content

aws_sdk_databasemigration/types/
_canned_acl_for_objects_value.rs

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