Skip to main content

aws_sdk_devicefarm/types/
_device_filter_attribute.rs

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