aws_sdk_machinelearning/types/
_data_source_filter_variable.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// When writing a match expression against `DataSourceFilterVariable`, 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 datasourcefiltervariable = unimplemented!();
14/// match datasourcefiltervariable {
15///     DataSourceFilterVariable::CreatedAt => { /* ... */ },
16///     DataSourceFilterVariable::DataUri => { /* ... */ },
17///     DataSourceFilterVariable::IamUser => { /* ... */ },
18///     DataSourceFilterVariable::LastUpdatedAt => { /* ... */ },
19///     DataSourceFilterVariable::Name => { /* ... */ },
20///     DataSourceFilterVariable::Status => { /* ... */ },
21///     other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
22///     _ => { /* ... */ },
23/// }
24/// ```
25/// The above code demonstrates that when `datasourcefiltervariable` represents
26/// `NewFeature`, the execution path will lead to the second last match arm,
27/// even though the enum does not contain a variant `DataSourceFilterVariable::NewFeature`
28/// in the current version of SDK. The reason is that the variable `other`,
29/// created by the `@` operator, is bound to
30/// `DataSourceFilterVariable::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 `DataSourceFilterVariable::NewFeature` is defined.
34/// Specifically, when `datasourcefiltervariable` represents `NewFeature`,
35/// the execution path will hit the second last match arm as before by virtue of
36/// calling `as_str` on `DataSourceFilterVariable::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/// <p>A list of the variables to use in searching or filtering <code>DataSource</code>.</p>    
44/// <ul>
45/// <li>
46/// <p>
47/// <code>CreatedAt</code> - Sets the search criteria to <code>DataSource</code> creation date.</p>
48/// </li>
49/// <li>
50/// <p>
51/// <code>Status</code> - Sets the search criteria to <code>DataSource</code> status.</p>
52/// </li>
53/// <li>
54/// <p>
55/// <code>Name</code> - Sets the search criteria to the contents of <code>DataSource</code>
56/// <code>Name</code>.</p>
57/// </li>
58/// <li>
59/// <p>
60/// <code>DataUri</code> - Sets the search criteria to the URI of data files used to create the <code>DataSource</code>. The URI can identify either a file or an Amazon Simple Storage Service (Amazon S3) bucket or directory.</p>
61/// </li>
62/// <li>
63/// <p>
64/// <code>IAMUser</code> - Sets the search criteria to the user account that invoked the <code>DataSource</code> creation.</p>
65/// </li>
66/// </ul>
67///
68/// <p>
69/// <b>Note:</b>
70/// The variable names should match the variable names in the <code>DataSource</code>.</p>
71#[non_exhaustive]
72#[derive(
73    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
74)]
75pub enum DataSourceFilterVariable {
76    #[allow(missing_docs)] // documentation missing in model
77    CreatedAt,
78    #[allow(missing_docs)] // documentation missing in model
79    DataUri,
80    #[allow(missing_docs)] // documentation missing in model
81    IamUser,
82    #[allow(missing_docs)] // documentation missing in model
83    LastUpdatedAt,
84    #[allow(missing_docs)] // documentation missing in model
85    Name,
86    #[allow(missing_docs)] // documentation missing in model
87    Status,
88    /// `Unknown` contains new variants that have been added since this code was generated.
89    #[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
90    Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
91}
92impl ::std::convert::From<&str> for DataSourceFilterVariable {
93    fn from(s: &str) -> Self {
94        match s {
95            "CreatedAt" => DataSourceFilterVariable::CreatedAt,
96            "DataLocationS3" => DataSourceFilterVariable::DataUri,
97            "IAMUser" => DataSourceFilterVariable::IamUser,
98            "LastUpdatedAt" => DataSourceFilterVariable::LastUpdatedAt,
99            "Name" => DataSourceFilterVariable::Name,
100            "Status" => DataSourceFilterVariable::Status,
101            other => DataSourceFilterVariable::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
102        }
103    }
104}
105impl ::std::str::FromStr for DataSourceFilterVariable {
106    type Err = ::std::convert::Infallible;
107
108    fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
109        ::std::result::Result::Ok(DataSourceFilterVariable::from(s))
110    }
111}
112impl DataSourceFilterVariable {
113    /// Returns the `&str` value of the enum member.
114    pub fn as_str(&self) -> &str {
115        match self {
116            DataSourceFilterVariable::CreatedAt => "CreatedAt",
117            DataSourceFilterVariable::DataUri => "DataLocationS3",
118            DataSourceFilterVariable::IamUser => "IAMUser",
119            DataSourceFilterVariable::LastUpdatedAt => "LastUpdatedAt",
120            DataSourceFilterVariable::Name => "Name",
121            DataSourceFilterVariable::Status => "Status",
122            DataSourceFilterVariable::Unknown(value) => value.as_str(),
123        }
124    }
125    /// Returns all the `&str` representations of the enum members.
126    pub const fn values() -> &'static [&'static str] {
127        &["CreatedAt", "DataLocationS3", "IAMUser", "LastUpdatedAt", "Name", "Status"]
128    }
129}
130impl ::std::convert::AsRef<str> for DataSourceFilterVariable {
131    fn as_ref(&self) -> &str {
132        self.as_str()
133    }
134}
135impl DataSourceFilterVariable {
136    /// Parses the enum value while disallowing unknown variants.
137    ///
138    /// Unknown variants will result in an error.
139    pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
140        match Self::from(value) {
141            #[allow(deprecated)]
142            Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
143            known => Ok(known),
144        }
145    }
146}
147impl ::std::fmt::Display for DataSourceFilterVariable {
148    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
149        match self {
150            DataSourceFilterVariable::CreatedAt => write!(f, "CreatedAt"),
151            DataSourceFilterVariable::DataUri => write!(f, "DataLocationS3"),
152            DataSourceFilterVariable::IamUser => write!(f, "IAMUser"),
153            DataSourceFilterVariable::LastUpdatedAt => write!(f, "LastUpdatedAt"),
154            DataSourceFilterVariable::Name => write!(f, "Name"),
155            DataSourceFilterVariable::Status => write!(f, "Status"),
156            DataSourceFilterVariable::Unknown(value) => write!(f, "{}", value),
157        }
158    }
159}