Enum aws_sdk_ec2::model::ImdsSupportValues
source · #[non_exhaustive]
pub enum ImdsSupportValues {
V20,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against ImdsSupportValues
, 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 imdssupportvalues = unimplemented!();
match imdssupportvalues {
ImdsSupportValues::V20 => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when imdssupportvalues
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant ImdsSupportValues::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
ImdsSupportValues::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 ImdsSupportValues::NewFeature
is defined.
Specifically, when imdssupportvalues
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on ImdsSupportValues::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
V20
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl ImdsSupportValues
impl ImdsSupportValues
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
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 ImdsSupportValues
impl AsRef<str> for ImdsSupportValues
source§impl Clone for ImdsSupportValues
impl Clone for ImdsSupportValues
source§fn clone(&self) -> ImdsSupportValues
fn clone(&self) -> ImdsSupportValues
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ImdsSupportValues
impl Debug for ImdsSupportValues
source§impl From<&str> for ImdsSupportValues
impl From<&str> for ImdsSupportValues
source§impl FromStr for ImdsSupportValues
impl FromStr for ImdsSupportValues
source§impl Hash for ImdsSupportValues
impl Hash for ImdsSupportValues
source§impl Ord for ImdsSupportValues
impl Ord for ImdsSupportValues
source§fn cmp(&self, other: &ImdsSupportValues) -> Ordering
fn cmp(&self, other: &ImdsSupportValues) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<ImdsSupportValues> for ImdsSupportValues
impl PartialEq<ImdsSupportValues> for ImdsSupportValues
source§fn eq(&self, other: &ImdsSupportValues) -> bool
fn eq(&self, other: &ImdsSupportValues) -> bool
source§impl PartialOrd<ImdsSupportValues> for ImdsSupportValues
impl PartialOrd<ImdsSupportValues> for ImdsSupportValues
source§fn partial_cmp(&self, other: &ImdsSupportValues) -> Option<Ordering>
fn partial_cmp(&self, other: &ImdsSupportValues) -> 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 ImdsSupportValues
impl StructuralEq for ImdsSupportValues
impl StructuralPartialEq for ImdsSupportValues
Auto Trait Implementations§
impl RefUnwindSafe for ImdsSupportValues
impl Send for ImdsSupportValues
impl Sync for ImdsSupportValues
impl Unpin for ImdsSupportValues
impl UnwindSafe for ImdsSupportValues
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.