Enum aws_sdk_ec2::model::PlatformValues
source · #[non_exhaustive]
pub enum PlatformValues {
Windows,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against PlatformValues
, it is important to ensure
your code is forward-compatible. That is, if a match arm handles a case for a
feature that is supported by the service but has not been represented as an enum
variant in a current version of SDK, your code should continue to work when you
upgrade SDK to a future version in which the enum does include a variant for that
feature.
Here is an example of how you can make a match expression forward-compatible:
# let platformvalues = unimplemented!();
match platformvalues {
PlatformValues::Windows => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when platformvalues
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant PlatformValues::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
PlatformValues::Unknown(UnknownVariantValue("NewFeature".to_owned()))
and calling as_str
on it yields "NewFeature"
.
This match expression is forward-compatible when executed with a newer
version of SDK where the variant PlatformValues::NewFeature
is defined.
Specifically, when platformvalues
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on PlatformValues::NewFeature
also yielding "NewFeature"
.
Explicitly matching on the Unknown
variant should
be avoided for two reasons:
- The inner data
UnknownVariantValue
is opaque, and no further information can be extracted. - It might inadvertently shadow other intended match arms.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Windows
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl PlatformValues
impl PlatformValues
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the &str
value of the enum member.
Examples found in repository?
More examples
16865 16866 16867 16868 16869 16870 16871 16872 16873 16874 16875 16876 16877 16878 16879 16880 16881 16882 16883 16884 16885 16886 16887 16888 16889 16890 16891 16892 16893 16894 16895 16896 16897 16898 16899 16900 16901 16902 16903 16904 16905 16906
pub fn serialize_operation_crate_operation_import_instance(
input: &crate::input::ImportInstanceInput,
) -> Result<aws_smithy_http::body::SdkBody, aws_smithy_http::operation::error::SerializationError> {
let mut out = String::new();
#[allow(unused_mut)]
let mut writer = aws_smithy_query::QueryWriter::new(&mut out, "ImportInstance", "2016-11-15");
#[allow(unused_mut)]
let mut scope_4726 = writer.prefix("Description");
if let Some(var_4727) = &input.description {
scope_4726.string(var_4727);
}
#[allow(unused_mut)]
let mut scope_4728 = writer.prefix("DiskImage");
if let Some(var_4729) = &input.disk_images {
let mut list_4731 = scope_4728.start_list(true, None);
for item_4730 in var_4729 {
#[allow(unused_mut)]
let mut entry_4732 = list_4731.entry();
crate::query_ser::serialize_structure_crate_model_disk_image(entry_4732, item_4730)?;
}
list_4731.finish();
}
#[allow(unused_mut)]
let mut scope_4733 = writer.prefix("DryRun");
if let Some(var_4734) = &input.dry_run {
scope_4733.boolean(*var_4734);
}
#[allow(unused_mut)]
let mut scope_4735 = writer.prefix("LaunchSpecification");
if let Some(var_4736) = &input.launch_specification {
crate::query_ser::serialize_structure_crate_model_import_instance_launch_specification(
scope_4735, var_4736,
)?;
}
#[allow(unused_mut)]
let mut scope_4737 = writer.prefix("Platform");
if let Some(var_4738) = &input.platform {
scope_4737.string(var_4738.as_str());
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}
Trait Implementations§
source§impl AsRef<str> for PlatformValues
impl AsRef<str> for PlatformValues
source§impl Clone for PlatformValues
impl Clone for PlatformValues
source§fn clone(&self) -> PlatformValues
fn clone(&self) -> PlatformValues
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PlatformValues
impl Debug for PlatformValues
source§impl From<&str> for PlatformValues
impl From<&str> for PlatformValues
source§impl FromStr for PlatformValues
impl FromStr for PlatformValues
source§impl Hash for PlatformValues
impl Hash for PlatformValues
source§impl Ord for PlatformValues
impl Ord for PlatformValues
source§fn cmp(&self, other: &PlatformValues) -> Ordering
fn cmp(&self, other: &PlatformValues) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<PlatformValues> for PlatformValues
impl PartialEq<PlatformValues> for PlatformValues
source§fn eq(&self, other: &PlatformValues) -> bool
fn eq(&self, other: &PlatformValues) -> bool
source§impl PartialOrd<PlatformValues> for PlatformValues
impl PartialOrd<PlatformValues> for PlatformValues
source§fn partial_cmp(&self, other: &PlatformValues) -> Option<Ordering>
fn partial_cmp(&self, other: &PlatformValues) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Eq for PlatformValues
impl StructuralEq for PlatformValues
impl StructuralPartialEq for PlatformValues
Auto Trait Implementations§
impl RefUnwindSafe for PlatformValues
impl Send for PlatformValues
impl Sync for PlatformValues
impl Unpin for PlatformValues
impl UnwindSafe for PlatformValues
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.