Enum aws_sdk_batch::model::CrAllocationStrategy
source · #[non_exhaustive]
pub enum CrAllocationStrategy {
BestFit,
BestFitProgressive,
SpotCapacityOptimized,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against CrAllocationStrategy
, 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 crallocationstrategy = unimplemented!();
match crallocationstrategy {
CrAllocationStrategy::BestFit => { /* ... */ },
CrAllocationStrategy::BestFitProgressive => { /* ... */ },
CrAllocationStrategy::SpotCapacityOptimized => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when crallocationstrategy
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant CrAllocationStrategy::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
CrAllocationStrategy::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 CrAllocationStrategy::NewFeature
is defined.
Specifically, when crallocationstrategy
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on CrAllocationStrategy::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
BestFit
BestFitProgressive
SpotCapacityOptimized
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl CrAllocationStrategy
impl CrAllocationStrategy
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
638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749
pub fn serialize_structure_crate_model_compute_resource(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::model::ComputeResource,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_148) = &input.r#type {
object.key("type").string(var_148.as_str());
}
if let Some(var_149) = &input.allocation_strategy {
object.key("allocationStrategy").string(var_149.as_str());
}
if let Some(var_150) = &input.minv_cpus {
object.key("minvCpus").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_150).into()),
);
}
if let Some(var_151) = &input.maxv_cpus {
object.key("maxvCpus").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_151).into()),
);
}
if let Some(var_152) = &input.desiredv_cpus {
object.key("desiredvCpus").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_152).into()),
);
}
if let Some(var_153) = &input.instance_types {
let mut array_154 = object.key("instanceTypes").start_array();
for item_155 in var_153 {
{
array_154.value().string(item_155.as_str());
}
}
array_154.finish();
}
if let Some(var_156) = &input.image_id {
object.key("imageId").string(var_156.as_str());
}
if let Some(var_157) = &input.subnets {
let mut array_158 = object.key("subnets").start_array();
for item_159 in var_157 {
{
array_158.value().string(item_159.as_str());
}
}
array_158.finish();
}
if let Some(var_160) = &input.security_group_ids {
let mut array_161 = object.key("securityGroupIds").start_array();
for item_162 in var_160 {
{
array_161.value().string(item_162.as_str());
}
}
array_161.finish();
}
if let Some(var_163) = &input.ec2_key_pair {
object.key("ec2KeyPair").string(var_163.as_str());
}
if let Some(var_164) = &input.instance_role {
object.key("instanceRole").string(var_164.as_str());
}
if let Some(var_165) = &input.tags {
#[allow(unused_mut)]
let mut object_166 = object.key("tags").start_object();
for (key_167, value_168) in var_165 {
{
object_166.key(key_167.as_str()).string(value_168.as_str());
}
}
object_166.finish();
}
if let Some(var_169) = &input.placement_group {
object.key("placementGroup").string(var_169.as_str());
}
if let Some(var_170) = &input.bid_percentage {
object.key("bidPercentage").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_170).into()),
);
}
if let Some(var_171) = &input.spot_iam_fleet_role {
object.key("spotIamFleetRole").string(var_171.as_str());
}
if let Some(var_172) = &input.launch_template {
#[allow(unused_mut)]
let mut object_173 = object.key("launchTemplate").start_object();
crate::json_ser::serialize_structure_crate_model_launch_template_specification(
&mut object_173,
var_172,
)?;
object_173.finish();
}
if let Some(var_174) = &input.ec2_configuration {
let mut array_175 = object.key("ec2Configuration").start_array();
for item_176 in var_174 {
{
#[allow(unused_mut)]
let mut object_177 = array_175.value().start_object();
crate::json_ser::serialize_structure_crate_model_ec2_configuration(
&mut object_177,
item_176,
)?;
object_177.finish();
}
}
array_175.finish();
}
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for CrAllocationStrategy
impl AsRef<str> for CrAllocationStrategy
source§impl Clone for CrAllocationStrategy
impl Clone for CrAllocationStrategy
source§fn clone(&self) -> CrAllocationStrategy
fn clone(&self) -> CrAllocationStrategy
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for CrAllocationStrategy
impl Debug for CrAllocationStrategy
source§impl From<&str> for CrAllocationStrategy
impl From<&str> for CrAllocationStrategy
source§impl FromStr for CrAllocationStrategy
impl FromStr for CrAllocationStrategy
source§impl Hash for CrAllocationStrategy
impl Hash for CrAllocationStrategy
source§impl Ord for CrAllocationStrategy
impl Ord for CrAllocationStrategy
source§fn cmp(&self, other: &CrAllocationStrategy) -> Ordering
fn cmp(&self, other: &CrAllocationStrategy) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<CrAllocationStrategy> for CrAllocationStrategy
impl PartialEq<CrAllocationStrategy> for CrAllocationStrategy
source§fn eq(&self, other: &CrAllocationStrategy) -> bool
fn eq(&self, other: &CrAllocationStrategy) -> bool
source§impl PartialOrd<CrAllocationStrategy> for CrAllocationStrategy
impl PartialOrd<CrAllocationStrategy> for CrAllocationStrategy
source§fn partial_cmp(&self, other: &CrAllocationStrategy) -> Option<Ordering>
fn partial_cmp(&self, other: &CrAllocationStrategy) -> 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 CrAllocationStrategy
impl StructuralEq for CrAllocationStrategy
impl StructuralPartialEq for CrAllocationStrategy
Auto Trait Implementations§
impl RefUnwindSafe for CrAllocationStrategy
impl Send for CrAllocationStrategy
impl Sync for CrAllocationStrategy
impl Unpin for CrAllocationStrategy
impl UnwindSafe for CrAllocationStrategy
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.