Enum aws_sdk_ec2::model::ArchitectureValues
source · #[non_exhaustive]
pub enum ArchitectureValues {
Arm64,
I386,
X8664,
X8664Mac,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against ArchitectureValues
, 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 architecturevalues = unimplemented!();
match architecturevalues {
ArchitectureValues::Arm64 => { /* ... */ },
ArchitectureValues::I386 => { /* ... */ },
ArchitectureValues::X8664 => { /* ... */ },
ArchitectureValues::X8664Mac => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when architecturevalues
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant ArchitectureValues::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
ArchitectureValues::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 ArchitectureValues::NewFeature
is defined.
Specifically, when architecturevalues
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on ArchitectureValues::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
Arm64
I386
X8664
X8664Mac
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl ArchitectureValues
impl ArchitectureValues
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
1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050
pub fn serialize_structure_crate_model_import_instance_launch_specification(
mut writer: aws_smithy_query::QueryValueWriter,
input: &crate::model::ImportInstanceLaunchSpecification,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
#[allow(unused_mut)]
let mut scope_563 = writer.prefix("AdditionalInfo");
if let Some(var_564) = &input.additional_info {
scope_563.string(var_564);
}
#[allow(unused_mut)]
let mut scope_565 = writer.prefix("Architecture");
if let Some(var_566) = &input.architecture {
scope_565.string(var_566.as_str());
}
#[allow(unused_mut)]
let mut scope_567 = writer.prefix("GroupId");
if let Some(var_568) = &input.group_ids {
let mut list_570 = scope_567.start_list(true, Some("SecurityGroupId"));
for item_569 in var_568 {
#[allow(unused_mut)]
let mut entry_571 = list_570.entry();
entry_571.string(item_569);
}
list_570.finish();
}
#[allow(unused_mut)]
let mut scope_572 = writer.prefix("GroupName");
if let Some(var_573) = &input.group_names {
let mut list_575 = scope_572.start_list(true, Some("SecurityGroup"));
for item_574 in var_573 {
#[allow(unused_mut)]
let mut entry_576 = list_575.entry();
entry_576.string(item_574);
}
list_575.finish();
}
#[allow(unused_mut)]
let mut scope_577 = writer.prefix("InstanceInitiatedShutdownBehavior");
if let Some(var_578) = &input.instance_initiated_shutdown_behavior {
scope_577.string(var_578.as_str());
}
#[allow(unused_mut)]
let mut scope_579 = writer.prefix("InstanceType");
if let Some(var_580) = &input.instance_type {
scope_579.string(var_580.as_str());
}
#[allow(unused_mut)]
let mut scope_581 = writer.prefix("Monitoring");
if let Some(var_582) = &input.monitoring {
scope_581.boolean(*var_582);
}
#[allow(unused_mut)]
let mut scope_583 = writer.prefix("Placement");
if let Some(var_584) = &input.placement {
crate::query_ser::serialize_structure_crate_model_placement(scope_583, var_584)?;
}
#[allow(unused_mut)]
let mut scope_585 = writer.prefix("PrivateIpAddress");
if let Some(var_586) = &input.private_ip_address {
scope_585.string(var_586);
}
#[allow(unused_mut)]
let mut scope_587 = writer.prefix("SubnetId");
if let Some(var_588) = &input.subnet_id {
scope_587.string(var_588);
}
#[allow(unused_mut)]
let mut scope_589 = writer.prefix("UserData");
if let Some(var_590) = &input.user_data {
crate::query_ser::serialize_structure_crate_model_user_data(scope_589, var_590)?;
}
Ok(())
}
20200 20201 20202 20203 20204 20205 20206 20207 20208 20209 20210 20211 20212 20213 20214 20215 20216 20217 20218 20219 20220 20221 20222 20223 20224 20225 20226 20227 20228 20229 20230 20231 20232 20233 20234 20235 20236 20237 20238 20239 20240 20241 20242 20243 20244 20245 20246 20247 20248 20249 20250 20251 20252 20253 20254 20255 20256 20257 20258 20259 20260 20261 20262 20263 20264 20265 20266 20267 20268 20269 20270 20271 20272 20273 20274 20275 20276 20277 20278 20279 20280 20281 20282 20283 20284 20285 20286 20287 20288 20289 20290 20291 20292 20293 20294 20295 20296 20297 20298 20299 20300 20301 20302 20303 20304 20305 20306 20307
pub fn serialize_operation_crate_operation_register_image(
input: &crate::input::RegisterImageInput,
) -> 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, "RegisterImage", "2016-11-15");
#[allow(unused_mut)]
let mut scope_5692 = writer.prefix("ImageLocation");
if let Some(var_5693) = &input.image_location {
scope_5692.string(var_5693);
}
#[allow(unused_mut)]
let mut scope_5694 = writer.prefix("Architecture");
if let Some(var_5695) = &input.architecture {
scope_5694.string(var_5695.as_str());
}
#[allow(unused_mut)]
let mut scope_5696 = writer.prefix("BlockDeviceMapping");
if let Some(var_5697) = &input.block_device_mappings {
let mut list_5699 = scope_5696.start_list(true, Some("BlockDeviceMapping"));
for item_5698 in var_5697 {
#[allow(unused_mut)]
let mut entry_5700 = list_5699.entry();
crate::query_ser::serialize_structure_crate_model_block_device_mapping(
entry_5700, item_5698,
)?;
}
list_5699.finish();
}
#[allow(unused_mut)]
let mut scope_5701 = writer.prefix("Description");
if let Some(var_5702) = &input.description {
scope_5701.string(var_5702);
}
#[allow(unused_mut)]
let mut scope_5703 = writer.prefix("DryRun");
if let Some(var_5704) = &input.dry_run {
scope_5703.boolean(*var_5704);
}
#[allow(unused_mut)]
let mut scope_5705 = writer.prefix("EnaSupport");
if let Some(var_5706) = &input.ena_support {
scope_5705.boolean(*var_5706);
}
#[allow(unused_mut)]
let mut scope_5707 = writer.prefix("KernelId");
if let Some(var_5708) = &input.kernel_id {
scope_5707.string(var_5708);
}
#[allow(unused_mut)]
let mut scope_5709 = writer.prefix("Name");
if let Some(var_5710) = &input.name {
scope_5709.string(var_5710);
}
#[allow(unused_mut)]
let mut scope_5711 = writer.prefix("BillingProduct");
if let Some(var_5712) = &input.billing_products {
let mut list_5714 = scope_5711.start_list(true, Some("item"));
for item_5713 in var_5712 {
#[allow(unused_mut)]
let mut entry_5715 = list_5714.entry();
entry_5715.string(item_5713);
}
list_5714.finish();
}
#[allow(unused_mut)]
let mut scope_5716 = writer.prefix("RamdiskId");
if let Some(var_5717) = &input.ramdisk_id {
scope_5716.string(var_5717);
}
#[allow(unused_mut)]
let mut scope_5718 = writer.prefix("RootDeviceName");
if let Some(var_5719) = &input.root_device_name {
scope_5718.string(var_5719);
}
#[allow(unused_mut)]
let mut scope_5720 = writer.prefix("SriovNetSupport");
if let Some(var_5721) = &input.sriov_net_support {
scope_5720.string(var_5721);
}
#[allow(unused_mut)]
let mut scope_5722 = writer.prefix("VirtualizationType");
if let Some(var_5723) = &input.virtualization_type {
scope_5722.string(var_5723);
}
#[allow(unused_mut)]
let mut scope_5724 = writer.prefix("BootMode");
if let Some(var_5725) = &input.boot_mode {
scope_5724.string(var_5725.as_str());
}
#[allow(unused_mut)]
let mut scope_5726 = writer.prefix("TpmSupport");
if let Some(var_5727) = &input.tpm_support {
scope_5726.string(var_5727.as_str());
}
#[allow(unused_mut)]
let mut scope_5728 = writer.prefix("UefiData");
if let Some(var_5729) = &input.uefi_data {
scope_5728.string(var_5729);
}
#[allow(unused_mut)]
let mut scope_5730 = writer.prefix("ImdsSupport");
if let Some(var_5731) = &input.imds_support {
scope_5730.string(var_5731.as_str());
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}
Trait Implementations§
source§impl AsRef<str> for ArchitectureValues
impl AsRef<str> for ArchitectureValues
source§impl Clone for ArchitectureValues
impl Clone for ArchitectureValues
source§fn clone(&self) -> ArchitectureValues
fn clone(&self) -> ArchitectureValues
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ArchitectureValues
impl Debug for ArchitectureValues
source§impl From<&str> for ArchitectureValues
impl From<&str> for ArchitectureValues
source§impl FromStr for ArchitectureValues
impl FromStr for ArchitectureValues
source§impl Hash for ArchitectureValues
impl Hash for ArchitectureValues
source§impl Ord for ArchitectureValues
impl Ord for ArchitectureValues
source§fn cmp(&self, other: &ArchitectureValues) -> Ordering
fn cmp(&self, other: &ArchitectureValues) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<ArchitectureValues> for ArchitectureValues
impl PartialEq<ArchitectureValues> for ArchitectureValues
source§fn eq(&self, other: &ArchitectureValues) -> bool
fn eq(&self, other: &ArchitectureValues) -> bool
source§impl PartialOrd<ArchitectureValues> for ArchitectureValues
impl PartialOrd<ArchitectureValues> for ArchitectureValues
source§fn partial_cmp(&self, other: &ArchitectureValues) -> Option<Ordering>
fn partial_cmp(&self, other: &ArchitectureValues) -> 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 ArchitectureValues
impl StructuralEq for ArchitectureValues
impl StructuralPartialEq for ArchitectureValues
Auto Trait Implementations§
impl RefUnwindSafe for ArchitectureValues
impl Send for ArchitectureValues
impl Sync for ArchitectureValues
impl Unpin for ArchitectureValues
impl UnwindSafe for ArchitectureValues
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.