Enum aws_sdk_elasticache::model::SourceType
source · #[non_exhaustive]
pub enum SourceType {
CacheCluster,
CacheParameterGroup,
CacheSecurityGroup,
CacheSubnetGroup,
ReplicationGroup,
User,
UserGroup,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against SourceType
, 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 sourcetype = unimplemented!();
match sourcetype {
SourceType::CacheCluster => { /* ... */ },
SourceType::CacheParameterGroup => { /* ... */ },
SourceType::CacheSecurityGroup => { /* ... */ },
SourceType::CacheSubnetGroup => { /* ... */ },
SourceType::ReplicationGroup => { /* ... */ },
SourceType::User => { /* ... */ },
SourceType::UserGroup => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when sourcetype
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant SourceType::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
SourceType::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 SourceType::NewFeature
is defined.
Specifically, when sourcetype
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on SourceType::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
CacheCluster
CacheParameterGroup
CacheSecurityGroup
CacheSubnetGroup
ReplicationGroup
User
UserGroup
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl SourceType
impl SourceType
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
1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477
pub fn serialize_operation_crate_operation_describe_events(
input: &crate::input::DescribeEventsInput,
) -> 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, "DescribeEvents", "2015-02-02");
#[allow(unused_mut)]
let mut scope_417 = writer.prefix("SourceIdentifier");
if let Some(var_418) = &input.source_identifier {
scope_417.string(var_418);
}
#[allow(unused_mut)]
let mut scope_419 = writer.prefix("SourceType");
if let Some(var_420) = &input.source_type {
scope_419.string(var_420.as_str());
}
#[allow(unused_mut)]
let mut scope_421 = writer.prefix("StartTime");
if let Some(var_422) = &input.start_time {
scope_421.date_time(var_422, aws_smithy_types::date_time::Format::DateTime)?;
}
#[allow(unused_mut)]
let mut scope_423 = writer.prefix("EndTime");
if let Some(var_424) = &input.end_time {
scope_423.date_time(var_424, aws_smithy_types::date_time::Format::DateTime)?;
}
#[allow(unused_mut)]
let mut scope_425 = writer.prefix("Duration");
if let Some(var_426) = &input.duration {
scope_425.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_426).into()),
);
}
#[allow(unused_mut)]
let mut scope_427 = writer.prefix("MaxRecords");
if let Some(var_428) = &input.max_records {
scope_427.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_428).into()),
);
}
#[allow(unused_mut)]
let mut scope_429 = writer.prefix("Marker");
if let Some(var_430) = &input.marker {
scope_429.string(var_430);
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}
Trait Implementations§
source§impl AsRef<str> for SourceType
impl AsRef<str> for SourceType
source§impl Clone for SourceType
impl Clone for SourceType
source§fn clone(&self) -> SourceType
fn clone(&self) -> SourceType
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for SourceType
impl Debug for SourceType
source§impl From<&str> for SourceType
impl From<&str> for SourceType
source§impl FromStr for SourceType
impl FromStr for SourceType
source§impl Hash for SourceType
impl Hash for SourceType
source§impl Ord for SourceType
impl Ord for SourceType
source§fn cmp(&self, other: &SourceType) -> Ordering
fn cmp(&self, other: &SourceType) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<SourceType> for SourceType
impl PartialEq<SourceType> for SourceType
source§fn eq(&self, other: &SourceType) -> bool
fn eq(&self, other: &SourceType) -> bool
source§impl PartialOrd<SourceType> for SourceType
impl PartialOrd<SourceType> for SourceType
source§fn partial_cmp(&self, other: &SourceType) -> Option<Ordering>
fn partial_cmp(&self, other: &SourceType) -> 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 SourceType
impl StructuralEq for SourceType
impl StructuralPartialEq for SourceType
Auto Trait Implementations§
impl RefUnwindSafe for SourceType
impl Send for SourceType
impl Sync for SourceType
impl Unpin for SourceType
impl UnwindSafe for SourceType
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.