#[non_exhaustive]
pub enum ServiceUpdateStatus {
Available,
Cancelled,
Expired,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against ServiceUpdateStatus
, 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 serviceupdatestatus = unimplemented!();
match serviceupdatestatus {
ServiceUpdateStatus::Available => { /* ... */ },
ServiceUpdateStatus::Cancelled => { /* ... */ },
ServiceUpdateStatus::Expired => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when serviceupdatestatus
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant ServiceUpdateStatus::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
ServiceUpdateStatus::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 ServiceUpdateStatus::NewFeature
is defined.
Specifically, when serviceupdatestatus
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on ServiceUpdateStatus::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
Available
Cancelled
Expired
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl ServiceUpdateStatus
impl ServiceUpdateStatus
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
1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 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
pub fn serialize_operation_crate_operation_describe_service_updates(
input: &crate::input::DescribeServiceUpdatesInput,
) -> 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, "DescribeServiceUpdates", "2015-02-02");
#[allow(unused_mut)]
let mut scope_475 = writer.prefix("ServiceUpdateName");
if let Some(var_476) = &input.service_update_name {
scope_475.string(var_476);
}
#[allow(unused_mut)]
let mut scope_477 = writer.prefix("ServiceUpdateStatus");
if let Some(var_478) = &input.service_update_status {
let mut list_480 = scope_477.start_list(false, None);
for item_479 in var_478 {
#[allow(unused_mut)]
let mut entry_481 = list_480.entry();
entry_481.string(item_479.as_str());
}
list_480.finish();
}
#[allow(unused_mut)]
let mut scope_482 = writer.prefix("MaxRecords");
if let Some(var_483) = &input.max_records {
scope_482.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_483).into()),
);
}
#[allow(unused_mut)]
let mut scope_484 = writer.prefix("Marker");
if let Some(var_485) = &input.marker {
scope_484.string(var_485);
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}
pub fn serialize_operation_crate_operation_describe_snapshots(
input: &crate::input::DescribeSnapshotsInput,
) -> 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, "DescribeSnapshots", "2015-02-02");
#[allow(unused_mut)]
let mut scope_486 = writer.prefix("ReplicationGroupId");
if let Some(var_487) = &input.replication_group_id {
scope_486.string(var_487);
}
#[allow(unused_mut)]
let mut scope_488 = writer.prefix("CacheClusterId");
if let Some(var_489) = &input.cache_cluster_id {
scope_488.string(var_489);
}
#[allow(unused_mut)]
let mut scope_490 = writer.prefix("SnapshotName");
if let Some(var_491) = &input.snapshot_name {
scope_490.string(var_491);
}
#[allow(unused_mut)]
let mut scope_492 = writer.prefix("SnapshotSource");
if let Some(var_493) = &input.snapshot_source {
scope_492.string(var_493);
}
#[allow(unused_mut)]
let mut scope_494 = writer.prefix("Marker");
if let Some(var_495) = &input.marker {
scope_494.string(var_495);
}
#[allow(unused_mut)]
let mut scope_496 = writer.prefix("MaxRecords");
if let Some(var_497) = &input.max_records {
scope_496.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_497).into()),
);
}
#[allow(unused_mut)]
let mut scope_498 = writer.prefix("ShowNodeGroupConfig");
if let Some(var_499) = &input.show_node_group_config {
scope_498.boolean(*var_499);
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}
pub fn serialize_operation_crate_operation_describe_update_actions(
input: &crate::input::DescribeUpdateActionsInput,
) -> 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, "DescribeUpdateActions", "2015-02-02");
#[allow(unused_mut)]
let mut scope_500 = writer.prefix("ServiceUpdateName");
if let Some(var_501) = &input.service_update_name {
scope_500.string(var_501);
}
#[allow(unused_mut)]
let mut scope_502 = writer.prefix("ReplicationGroupIds");
if let Some(var_503) = &input.replication_group_ids {
let mut list_505 = scope_502.start_list(false, None);
for item_504 in var_503 {
#[allow(unused_mut)]
let mut entry_506 = list_505.entry();
entry_506.string(item_504);
}
list_505.finish();
}
#[allow(unused_mut)]
let mut scope_507 = writer.prefix("CacheClusterIds");
if let Some(var_508) = &input.cache_cluster_ids {
let mut list_510 = scope_507.start_list(false, None);
for item_509 in var_508 {
#[allow(unused_mut)]
let mut entry_511 = list_510.entry();
entry_511.string(item_509);
}
list_510.finish();
}
#[allow(unused_mut)]
let mut scope_512 = writer.prefix("Engine");
if let Some(var_513) = &input.engine {
scope_512.string(var_513);
}
#[allow(unused_mut)]
let mut scope_514 = writer.prefix("ServiceUpdateStatus");
if let Some(var_515) = &input.service_update_status {
let mut list_517 = scope_514.start_list(false, None);
for item_516 in var_515 {
#[allow(unused_mut)]
let mut entry_518 = list_517.entry();
entry_518.string(item_516.as_str());
}
list_517.finish();
}
#[allow(unused_mut)]
let mut scope_519 = writer.prefix("ServiceUpdateTimeRange");
if let Some(var_520) = &input.service_update_time_range {
crate::query_ser::serialize_structure_crate_model_time_range_filter(scope_519, var_520)?;
}
#[allow(unused_mut)]
let mut scope_521 = writer.prefix("UpdateActionStatus");
if let Some(var_522) = &input.update_action_status {
let mut list_524 = scope_521.start_list(false, None);
for item_523 in var_522 {
#[allow(unused_mut)]
let mut entry_525 = list_524.entry();
entry_525.string(item_523.as_str());
}
list_524.finish();
}
#[allow(unused_mut)]
let mut scope_526 = writer.prefix("ShowNodeLevelUpdateStatus");
if let Some(var_527) = &input.show_node_level_update_status {
scope_526.boolean(*var_527);
}
#[allow(unused_mut)]
let mut scope_528 = writer.prefix("MaxRecords");
if let Some(var_529) = &input.max_records {
scope_528.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_529).into()),
);
}
#[allow(unused_mut)]
let mut scope_530 = writer.prefix("Marker");
if let Some(var_531) = &input.marker {
scope_530.string(var_531);
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}
Trait Implementations§
source§impl AsRef<str> for ServiceUpdateStatus
impl AsRef<str> for ServiceUpdateStatus
source§impl Clone for ServiceUpdateStatus
impl Clone for ServiceUpdateStatus
source§fn clone(&self) -> ServiceUpdateStatus
fn clone(&self) -> ServiceUpdateStatus
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ServiceUpdateStatus
impl Debug for ServiceUpdateStatus
source§impl From<&str> for ServiceUpdateStatus
impl From<&str> for ServiceUpdateStatus
source§impl FromStr for ServiceUpdateStatus
impl FromStr for ServiceUpdateStatus
source§impl Hash for ServiceUpdateStatus
impl Hash for ServiceUpdateStatus
source§impl Ord for ServiceUpdateStatus
impl Ord for ServiceUpdateStatus
source§fn cmp(&self, other: &ServiceUpdateStatus) -> Ordering
fn cmp(&self, other: &ServiceUpdateStatus) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<ServiceUpdateStatus> for ServiceUpdateStatus
impl PartialEq<ServiceUpdateStatus> for ServiceUpdateStatus
source§fn eq(&self, other: &ServiceUpdateStatus) -> bool
fn eq(&self, other: &ServiceUpdateStatus) -> bool
source§impl PartialOrd<ServiceUpdateStatus> for ServiceUpdateStatus
impl PartialOrd<ServiceUpdateStatus> for ServiceUpdateStatus
source§fn partial_cmp(&self, other: &ServiceUpdateStatus) -> Option<Ordering>
fn partial_cmp(&self, other: &ServiceUpdateStatus) -> 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 ServiceUpdateStatus
impl StructuralEq for ServiceUpdateStatus
impl StructuralPartialEq for ServiceUpdateStatus
Auto Trait Implementations§
impl RefUnwindSafe for ServiceUpdateStatus
impl Send for ServiceUpdateStatus
impl Sync for ServiceUpdateStatus
impl Unpin for ServiceUpdateStatus
impl UnwindSafe for ServiceUpdateStatus
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.