#[non_exhaustive]
pub enum CrUpdateAllocationStrategy {
BestFitProgressive,
SpotCapacityOptimized,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against CrUpdateAllocationStrategy
, 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 crupdateallocationstrategy = unimplemented!();
match crupdateallocationstrategy {
CrUpdateAllocationStrategy::BestFitProgressive => { /* ... */ },
CrUpdateAllocationStrategy::SpotCapacityOptimized => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when crupdateallocationstrategy
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant CrUpdateAllocationStrategy::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
CrUpdateAllocationStrategy::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 CrUpdateAllocationStrategy::NewFeature
is defined.
Specifically, when crupdateallocationstrategy
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on CrUpdateAllocationStrategy::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
BestFitProgressive
SpotCapacityOptimized
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl CrUpdateAllocationStrategy
impl CrUpdateAllocationStrategy
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
1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287
pub fn serialize_structure_crate_model_compute_resource_update(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::ComputeResourceUpdate,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_268) = &input.minv_cpus {
object.key("minvCpus").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_268).into()),
);
}
if let Some(var_269) = &input.maxv_cpus {
object.key("maxvCpus").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_269).into()),
);
}
if let Some(var_270) = &input.desiredv_cpus {
object.key("desiredvCpus").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_270).into()),
);
}
if let Some(var_271) = &input.subnets {
let mut array_272 = object.key("subnets").start_array();
for item_273 in var_271 {
{
array_272.value().string(item_273.as_str());
}
}
array_272.finish();
}
if let Some(var_274) = &input.security_group_ids {
let mut array_275 = object.key("securityGroupIds").start_array();
for item_276 in var_274 {
{
array_275.value().string(item_276.as_str());
}
}
array_275.finish();
}
if let Some(var_277) = &input.allocation_strategy {
object.key("allocationStrategy").string(var_277.as_str());
}
if let Some(var_278) = &input.instance_types {
let mut array_279 = object.key("instanceTypes").start_array();
for item_280 in var_278 {
{
array_279.value().string(item_280.as_str());
}
}
array_279.finish();
}
if let Some(var_281) = &input.ec2_key_pair {
object.key("ec2KeyPair").string(var_281.as_str());
}
if let Some(var_282) = &input.instance_role {
object.key("instanceRole").string(var_282.as_str());
}
if let Some(var_283) = &input.tags {
#[allow(unused_mut)]
let mut object_284 = object.key("tags").start_object();
for (key_285, value_286) in var_283 {
{
object_284.key(key_285.as_str()).string(value_286.as_str());
}
}
object_284.finish();
}
if let Some(var_287) = &input.placement_group {
object.key("placementGroup").string(var_287.as_str());
}
if let Some(var_288) = &input.bid_percentage {
object.key("bidPercentage").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_288).into()),
);
}
if let Some(var_289) = &input.launch_template {
#[allow(unused_mut)]
let mut object_290 = object.key("launchTemplate").start_object();
crate::json_ser::serialize_structure_crate_model_launch_template_specification(
&mut object_290,
var_289,
)?;
object_290.finish();
}
if let Some(var_291) = &input.ec2_configuration {
let mut array_292 = object.key("ec2Configuration").start_array();
for item_293 in var_291 {
{
#[allow(unused_mut)]
let mut object_294 = array_292.value().start_object();
crate::json_ser::serialize_structure_crate_model_ec2_configuration(
&mut object_294,
item_293,
)?;
object_294.finish();
}
}
array_292.finish();
}
if let Some(var_295) = &input.update_to_latest_image_version {
object.key("updateToLatestImageVersion").boolean(*var_295);
}
if let Some(var_296) = &input.r#type {
object.key("type").string(var_296.as_str());
}
if let Some(var_297) = &input.image_id {
object.key("imageId").string(var_297.as_str());
}
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for CrUpdateAllocationStrategy
impl AsRef<str> for CrUpdateAllocationStrategy
source§impl Clone for CrUpdateAllocationStrategy
impl Clone for CrUpdateAllocationStrategy
source§fn clone(&self) -> CrUpdateAllocationStrategy
fn clone(&self) -> CrUpdateAllocationStrategy
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for CrUpdateAllocationStrategy
impl Debug for CrUpdateAllocationStrategy
source§impl From<&str> for CrUpdateAllocationStrategy
impl From<&str> for CrUpdateAllocationStrategy
source§impl FromStr for CrUpdateAllocationStrategy
impl FromStr for CrUpdateAllocationStrategy
source§impl Hash for CrUpdateAllocationStrategy
impl Hash for CrUpdateAllocationStrategy
source§impl Ord for CrUpdateAllocationStrategy
impl Ord for CrUpdateAllocationStrategy
source§fn cmp(&self, other: &CrUpdateAllocationStrategy) -> Ordering
fn cmp(&self, other: &CrUpdateAllocationStrategy) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<CrUpdateAllocationStrategy> for CrUpdateAllocationStrategy
impl PartialEq<CrUpdateAllocationStrategy> for CrUpdateAllocationStrategy
source§fn eq(&self, other: &CrUpdateAllocationStrategy) -> bool
fn eq(&self, other: &CrUpdateAllocationStrategy) -> bool
source§impl PartialOrd<CrUpdateAllocationStrategy> for CrUpdateAllocationStrategy
impl PartialOrd<CrUpdateAllocationStrategy> for CrUpdateAllocationStrategy
source§fn partial_cmp(&self, other: &CrUpdateAllocationStrategy) -> Option<Ordering>
fn partial_cmp(&self, other: &CrUpdateAllocationStrategy) -> 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 CrUpdateAllocationStrategy
impl StructuralEq for CrUpdateAllocationStrategy
impl StructuralPartialEq for CrUpdateAllocationStrategy
Auto Trait Implementations§
impl RefUnwindSafe for CrUpdateAllocationStrategy
impl Send for CrUpdateAllocationStrategy
impl Sync for CrUpdateAllocationStrategy
impl Unpin for CrUpdateAllocationStrategy
impl UnwindSafe for CrUpdateAllocationStrategy
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.