#[non_exhaustive]
pub enum CapacityReservationTenancy {
Dedicated,
Default,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against CapacityReservationTenancy
, 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 capacityreservationtenancy = unimplemented!();
match capacityreservationtenancy {
CapacityReservationTenancy::Dedicated => { /* ... */ },
CapacityReservationTenancy::Default => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when capacityreservationtenancy
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant CapacityReservationTenancy::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
CapacityReservationTenancy::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 CapacityReservationTenancy::NewFeature
is defined.
Specifically, when capacityreservationtenancy
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on CapacityReservationTenancy::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
Dedicated
Default
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl CapacityReservationTenancy
impl CapacityReservationTenancy
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
1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884
pub fn serialize_operation_crate_operation_create_capacity_reservation(
input: &crate::input::CreateCapacityReservationInput,
) -> 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, "CreateCapacityReservation", "2016-11-15");
#[allow(unused_mut)]
let mut scope_483 = writer.prefix("ClientToken");
if let Some(var_484) = &input.client_token {
scope_483.string(var_484);
}
#[allow(unused_mut)]
let mut scope_485 = writer.prefix("InstanceType");
if let Some(var_486) = &input.instance_type {
scope_485.string(var_486);
}
#[allow(unused_mut)]
let mut scope_487 = writer.prefix("InstancePlatform");
if let Some(var_488) = &input.instance_platform {
scope_487.string(var_488.as_str());
}
#[allow(unused_mut)]
let mut scope_489 = writer.prefix("AvailabilityZone");
if let Some(var_490) = &input.availability_zone {
scope_489.string(var_490);
}
#[allow(unused_mut)]
let mut scope_491 = writer.prefix("AvailabilityZoneId");
if let Some(var_492) = &input.availability_zone_id {
scope_491.string(var_492);
}
#[allow(unused_mut)]
let mut scope_493 = writer.prefix("Tenancy");
if let Some(var_494) = &input.tenancy {
scope_493.string(var_494.as_str());
}
#[allow(unused_mut)]
let mut scope_495 = writer.prefix("InstanceCount");
if let Some(var_496) = &input.instance_count {
scope_495.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_496).into()),
);
}
#[allow(unused_mut)]
let mut scope_497 = writer.prefix("EbsOptimized");
if let Some(var_498) = &input.ebs_optimized {
scope_497.boolean(*var_498);
}
#[allow(unused_mut)]
let mut scope_499 = writer.prefix("EphemeralStorage");
if let Some(var_500) = &input.ephemeral_storage {
scope_499.boolean(*var_500);
}
#[allow(unused_mut)]
let mut scope_501 = writer.prefix("EndDate");
if let Some(var_502) = &input.end_date {
scope_501.date_time(var_502, aws_smithy_types::date_time::Format::DateTime)?;
}
#[allow(unused_mut)]
let mut scope_503 = writer.prefix("EndDateType");
if let Some(var_504) = &input.end_date_type {
scope_503.string(var_504.as_str());
}
#[allow(unused_mut)]
let mut scope_505 = writer.prefix("InstanceMatchCriteria");
if let Some(var_506) = &input.instance_match_criteria {
scope_505.string(var_506.as_str());
}
#[allow(unused_mut)]
let mut scope_507 = writer.prefix("TagSpecifications");
if let Some(var_508) = &input.tag_specifications {
let mut list_510 = scope_507.start_list(true, Some("item"));
for item_509 in var_508 {
#[allow(unused_mut)]
let mut entry_511 = list_510.entry();
crate::query_ser::serialize_structure_crate_model_tag_specification(
entry_511, item_509,
)?;
}
list_510.finish();
}
#[allow(unused_mut)]
let mut scope_512 = writer.prefix("DryRun");
if let Some(var_513) = &input.dry_run {
scope_512.boolean(*var_513);
}
#[allow(unused_mut)]
let mut scope_514 = writer.prefix("OutpostArn");
if let Some(var_515) = &input.outpost_arn {
scope_514.string(var_515);
}
#[allow(unused_mut)]
let mut scope_516 = writer.prefix("PlacementGroupArn");
if let Some(var_517) = &input.placement_group_arn {
scope_516.string(var_517);
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}
Trait Implementations§
source§impl AsRef<str> for CapacityReservationTenancy
impl AsRef<str> for CapacityReservationTenancy
source§impl Clone for CapacityReservationTenancy
impl Clone for CapacityReservationTenancy
source§fn clone(&self) -> CapacityReservationTenancy
fn clone(&self) -> CapacityReservationTenancy
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for CapacityReservationTenancy
impl Debug for CapacityReservationTenancy
source§impl From<&str> for CapacityReservationTenancy
impl From<&str> for CapacityReservationTenancy
source§impl FromStr for CapacityReservationTenancy
impl FromStr for CapacityReservationTenancy
source§impl Hash for CapacityReservationTenancy
impl Hash for CapacityReservationTenancy
source§impl Ord for CapacityReservationTenancy
impl Ord for CapacityReservationTenancy
source§fn cmp(&self, other: &CapacityReservationTenancy) -> Ordering
fn cmp(&self, other: &CapacityReservationTenancy) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<CapacityReservationTenancy> for CapacityReservationTenancy
impl PartialEq<CapacityReservationTenancy> for CapacityReservationTenancy
source§fn eq(&self, other: &CapacityReservationTenancy) -> bool
fn eq(&self, other: &CapacityReservationTenancy) -> bool
source§impl PartialOrd<CapacityReservationTenancy> for CapacityReservationTenancy
impl PartialOrd<CapacityReservationTenancy> for CapacityReservationTenancy
source§fn partial_cmp(&self, other: &CapacityReservationTenancy) -> Option<Ordering>
fn partial_cmp(&self, other: &CapacityReservationTenancy) -> 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 CapacityReservationTenancy
impl StructuralEq for CapacityReservationTenancy
impl StructuralPartialEq for CapacityReservationTenancy
Auto Trait Implementations§
impl RefUnwindSafe for CapacityReservationTenancy
impl Send for CapacityReservationTenancy
impl Sync for CapacityReservationTenancy
impl Unpin for CapacityReservationTenancy
impl UnwindSafe for CapacityReservationTenancy
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.