aws_sdk_s3control/types/
_operation_name.rs

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