Enum aws_sdk_ec2::model::ExportEnvironment
source · #[non_exhaustive]
pub enum ExportEnvironment {
Citrix,
Microsoft,
Vmware,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against ExportEnvironment
, 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 exportenvironment = unimplemented!();
match exportenvironment {
ExportEnvironment::Citrix => { /* ... */ },
ExportEnvironment::Microsoft => { /* ... */ },
ExportEnvironment::Vmware => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when exportenvironment
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant ExportEnvironment::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
ExportEnvironment::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 ExportEnvironment::NewFeature
is defined.
Specifically, when exportenvironment
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on ExportEnvironment::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
Citrix
Microsoft
Vmware
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl ExportEnvironment
impl ExportEnvironment
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
2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835
pub fn serialize_operation_crate_operation_create_instance_export_task(
input: &crate::input::CreateInstanceExportTaskInput,
) -> 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, "CreateInstanceExportTask", "2016-11-15");
#[allow(unused_mut)]
let mut scope_799 = writer.prefix("Description");
if let Some(var_800) = &input.description {
scope_799.string(var_800);
}
#[allow(unused_mut)]
let mut scope_801 = writer.prefix("ExportToS3");
if let Some(var_802) = &input.export_to_s3_task {
crate::query_ser::serialize_structure_crate_model_export_to_s3_task_specification(
scope_801, var_802,
)?;
}
#[allow(unused_mut)]
let mut scope_803 = writer.prefix("InstanceId");
if let Some(var_804) = &input.instance_id {
scope_803.string(var_804);
}
#[allow(unused_mut)]
let mut scope_805 = writer.prefix("TargetEnvironment");
if let Some(var_806) = &input.target_environment {
scope_805.string(var_806.as_str());
}
#[allow(unused_mut)]
let mut scope_807 = writer.prefix("TagSpecification");
if let Some(var_808) = &input.tag_specifications {
let mut list_810 = scope_807.start_list(true, Some("item"));
for item_809 in var_808 {
#[allow(unused_mut)]
let mut entry_811 = list_810.entry();
crate::query_ser::serialize_structure_crate_model_tag_specification(
entry_811, item_809,
)?;
}
list_810.finish();
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}
Trait Implementations§
source§impl AsRef<str> for ExportEnvironment
impl AsRef<str> for ExportEnvironment
source§impl Clone for ExportEnvironment
impl Clone for ExportEnvironment
source§fn clone(&self) -> ExportEnvironment
fn clone(&self) -> ExportEnvironment
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ExportEnvironment
impl Debug for ExportEnvironment
source§impl From<&str> for ExportEnvironment
impl From<&str> for ExportEnvironment
source§impl FromStr for ExportEnvironment
impl FromStr for ExportEnvironment
source§impl Hash for ExportEnvironment
impl Hash for ExportEnvironment
source§impl Ord for ExportEnvironment
impl Ord for ExportEnvironment
source§fn cmp(&self, other: &ExportEnvironment) -> Ordering
fn cmp(&self, other: &ExportEnvironment) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<ExportEnvironment> for ExportEnvironment
impl PartialEq<ExportEnvironment> for ExportEnvironment
source§fn eq(&self, other: &ExportEnvironment) -> bool
fn eq(&self, other: &ExportEnvironment) -> bool
source§impl PartialOrd<ExportEnvironment> for ExportEnvironment
impl PartialOrd<ExportEnvironment> for ExportEnvironment
source§fn partial_cmp(&self, other: &ExportEnvironment) -> Option<Ordering>
fn partial_cmp(&self, other: &ExportEnvironment) -> 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 ExportEnvironment
impl StructuralEq for ExportEnvironment
impl StructuralPartialEq for ExportEnvironment
Auto Trait Implementations§
impl RefUnwindSafe for ExportEnvironment
impl Send for ExportEnvironment
impl Sync for ExportEnvironment
impl Unpin for ExportEnvironment
impl UnwindSafe for ExportEnvironment
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.