Enum aws_sdk_s3control::model::S3SseAlgorithm
source · #[non_exhaustive]
pub enum S3SseAlgorithm {
Aes256,
Kms,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against S3SseAlgorithm
, 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 s3ssealgorithm = unimplemented!();
match s3ssealgorithm {
S3SseAlgorithm::Aes256 => { /* ... */ },
S3SseAlgorithm::Kms => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when s3ssealgorithm
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant S3SseAlgorithm::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
S3SseAlgorithm::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 S3SseAlgorithm::NewFeature
is defined.
Specifically, when s3ssealgorithm
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on S3SseAlgorithm::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
Aes256
Kms
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl S3SseAlgorithm
impl S3SseAlgorithm
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
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 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496
pub fn serialize_structure_crate_model_s3_object_metadata(
input: &crate::model::S3ObjectMetadata,
writer: aws_smithy_xml::encode::ElWriter,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
#[allow(unused_mut)]
let mut scope = writer.finish();
if let Some(var_155) = &input.cache_control {
let mut inner_writer = scope.start_el("CacheControl").finish();
inner_writer.data(var_155.as_str());
}
if let Some(var_156) = &input.content_disposition {
let mut inner_writer = scope.start_el("ContentDisposition").finish();
inner_writer.data(var_156.as_str());
}
if let Some(var_157) = &input.content_encoding {
let mut inner_writer = scope.start_el("ContentEncoding").finish();
inner_writer.data(var_157.as_str());
}
if let Some(var_158) = &input.content_language {
let mut inner_writer = scope.start_el("ContentLanguage").finish();
inner_writer.data(var_158.as_str());
}
if let Some(var_159) = &input.user_metadata {
let mut inner_writer = scope.start_el("UserMetadata").finish();
for (key_160, value_161) in var_159 {
let mut entry = inner_writer.start_el("entry").finish();
{
let mut inner_writer = entry.start_el("key").finish();
inner_writer.data(key_160.as_str());
}
{
let mut inner_writer = entry.start_el("value").finish();
inner_writer.data(value_161.as_str());
}
}
}
if let Some(var_162) = &input.content_length {
let mut inner_writer = scope.start_el("ContentLength").finish();
inner_writer.data(aws_smithy_types::primitive::Encoder::from(*var_162).encode());
}
if let Some(var_163) = &input.content_md5 {
let mut inner_writer = scope.start_el("ContentMD5").finish();
inner_writer.data(var_163.as_str());
}
if let Some(var_164) = &input.content_type {
let mut inner_writer = scope.start_el("ContentType").finish();
inner_writer.data(var_164.as_str());
}
if let Some(var_165) = &input.http_expires_date {
let mut inner_writer = scope.start_el("HttpExpiresDate").finish();
inner_writer.data(
var_165
.fmt(aws_smithy_types::date_time::Format::DateTime)?
.as_ref(),
);
}
if input.requester_charged {
let mut inner_writer = scope.start_el("RequesterCharged").finish();
inner_writer
.data(aws_smithy_types::primitive::Encoder::from(input.requester_charged).encode());
}
if let Some(var_166) = &input.sse_algorithm {
let mut inner_writer = scope.start_el("SSEAlgorithm").finish();
inner_writer.data(var_166.as_str());
}
scope.finish();
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for S3SseAlgorithm
impl AsRef<str> for S3SseAlgorithm
source§impl Clone for S3SseAlgorithm
impl Clone for S3SseAlgorithm
source§fn clone(&self) -> S3SseAlgorithm
fn clone(&self) -> S3SseAlgorithm
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for S3SseAlgorithm
impl Debug for S3SseAlgorithm
source§impl From<&str> for S3SseAlgorithm
impl From<&str> for S3SseAlgorithm
source§impl FromStr for S3SseAlgorithm
impl FromStr for S3SseAlgorithm
source§impl Hash for S3SseAlgorithm
impl Hash for S3SseAlgorithm
source§impl Ord for S3SseAlgorithm
impl Ord for S3SseAlgorithm
source§fn cmp(&self, other: &S3SseAlgorithm) -> Ordering
fn cmp(&self, other: &S3SseAlgorithm) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<S3SseAlgorithm> for S3SseAlgorithm
impl PartialEq<S3SseAlgorithm> for S3SseAlgorithm
source§fn eq(&self, other: &S3SseAlgorithm) -> bool
fn eq(&self, other: &S3SseAlgorithm) -> bool
source§impl PartialOrd<S3SseAlgorithm> for S3SseAlgorithm
impl PartialOrd<S3SseAlgorithm> for S3SseAlgorithm
source§fn partial_cmp(&self, other: &S3SseAlgorithm) -> Option<Ordering>
fn partial_cmp(&self, other: &S3SseAlgorithm) -> 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 S3SseAlgorithm
impl StructuralEq for S3SseAlgorithm
impl StructuralPartialEq for S3SseAlgorithm
Auto Trait Implementations§
impl RefUnwindSafe for S3SseAlgorithm
impl Send for S3SseAlgorithm
impl Sync for S3SseAlgorithm
impl Unpin for S3SseAlgorithm
impl UnwindSafe for S3SseAlgorithm
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.