#[non_exhaustive]
pub enum S3ChecksumAlgorithm {
Crc32,
Crc32C,
Sha1,
Sha256,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against S3ChecksumAlgorithm
, 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 s3checksumalgorithm = unimplemented!();
match s3checksumalgorithm {
S3ChecksumAlgorithm::Crc32 => { /* ... */ },
S3ChecksumAlgorithm::Crc32C => { /* ... */ },
S3ChecksumAlgorithm::Sha1 => { /* ... */ },
S3ChecksumAlgorithm::Sha256 => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when s3checksumalgorithm
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant S3ChecksumAlgorithm::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
S3ChecksumAlgorithm::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 S3ChecksumAlgorithm::NewFeature
is defined.
Specifically, when s3checksumalgorithm
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on S3ChecksumAlgorithm::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
Crc32
Crc32C
Sha1
Sha256
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl S3ChecksumAlgorithm
impl S3ChecksumAlgorithm
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
927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034
pub fn serialize_structure_crate_model_s3_copy_object_operation(
input: &crate::model::S3CopyObjectOperation,
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_93) = &input.target_resource {
let mut inner_writer = scope.start_el("TargetResource").finish();
inner_writer.data(var_93.as_str());
}
if let Some(var_94) = &input.canned_access_control_list {
let mut inner_writer = scope.start_el("CannedAccessControlList").finish();
inner_writer.data(var_94.as_str());
}
if let Some(var_95) = &input.access_control_grants {
let mut inner_writer = scope.start_el("AccessControlGrants").finish();
for list_item_96 in var_95 {
{
let inner_writer = inner_writer.start_el("member");
crate::xml_ser::serialize_structure_crate_model_s3_grant(
list_item_96,
inner_writer,
)?
}
}
}
if let Some(var_97) = &input.metadata_directive {
let mut inner_writer = scope.start_el("MetadataDirective").finish();
inner_writer.data(var_97.as_str());
}
if let Some(var_98) = &input.modified_since_constraint {
let mut inner_writer = scope.start_el("ModifiedSinceConstraint").finish();
inner_writer.data(
var_98
.fmt(aws_smithy_types::date_time::Format::DateTime)?
.as_ref(),
);
}
if let Some(var_99) = &input.new_object_metadata {
let inner_writer = scope.start_el("NewObjectMetadata");
crate::xml_ser::serialize_structure_crate_model_s3_object_metadata(var_99, inner_writer)?
}
if let Some(var_100) = &input.new_object_tagging {
let mut inner_writer = scope.start_el("NewObjectTagging").finish();
for list_item_101 in var_100 {
{
let inner_writer = inner_writer.start_el("member");
crate::xml_ser::serialize_structure_crate_model_s3_tag(list_item_101, inner_writer)?
}
}
}
if let Some(var_102) = &input.redirect_location {
let mut inner_writer = scope.start_el("RedirectLocation").finish();
inner_writer.data(var_102.as_str());
}
if input.requester_pays {
let mut inner_writer = scope.start_el("RequesterPays").finish();
inner_writer
.data(aws_smithy_types::primitive::Encoder::from(input.requester_pays).encode());
}
if let Some(var_103) = &input.storage_class {
let mut inner_writer = scope.start_el("StorageClass").finish();
inner_writer.data(var_103.as_str());
}
if let Some(var_104) = &input.un_modified_since_constraint {
let mut inner_writer = scope.start_el("UnModifiedSinceConstraint").finish();
inner_writer.data(
var_104
.fmt(aws_smithy_types::date_time::Format::DateTime)?
.as_ref(),
);
}
if let Some(var_105) = &input.sse_aws_kms_key_id {
let mut inner_writer = scope.start_el("SSEAwsKmsKeyId").finish();
inner_writer.data(var_105.as_str());
}
if let Some(var_106) = &input.target_key_prefix {
let mut inner_writer = scope.start_el("TargetKeyPrefix").finish();
inner_writer.data(var_106.as_str());
}
if let Some(var_107) = &input.object_lock_legal_hold_status {
let mut inner_writer = scope.start_el("ObjectLockLegalHoldStatus").finish();
inner_writer.data(var_107.as_str());
}
if let Some(var_108) = &input.object_lock_mode {
let mut inner_writer = scope.start_el("ObjectLockMode").finish();
inner_writer.data(var_108.as_str());
}
if let Some(var_109) = &input.object_lock_retain_until_date {
let mut inner_writer = scope.start_el("ObjectLockRetainUntilDate").finish();
inner_writer.data(
var_109
.fmt(aws_smithy_types::date_time::Format::DateTime)?
.as_ref(),
);
}
if input.bucket_key_enabled {
let mut inner_writer = scope.start_el("BucketKeyEnabled").finish();
inner_writer
.data(aws_smithy_types::primitive::Encoder::from(input.bucket_key_enabled).encode());
}
if let Some(var_110) = &input.checksum_algorithm {
let mut inner_writer = scope.start_el("ChecksumAlgorithm").finish();
inner_writer.data(var_110.as_str());
}
scope.finish();
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for S3ChecksumAlgorithm
impl AsRef<str> for S3ChecksumAlgorithm
source§impl Clone for S3ChecksumAlgorithm
impl Clone for S3ChecksumAlgorithm
source§fn clone(&self) -> S3ChecksumAlgorithm
fn clone(&self) -> S3ChecksumAlgorithm
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for S3ChecksumAlgorithm
impl Debug for S3ChecksumAlgorithm
source§impl From<&str> for S3ChecksumAlgorithm
impl From<&str> for S3ChecksumAlgorithm
source§impl FromStr for S3ChecksumAlgorithm
impl FromStr for S3ChecksumAlgorithm
source§impl Hash for S3ChecksumAlgorithm
impl Hash for S3ChecksumAlgorithm
source§impl Ord for S3ChecksumAlgorithm
impl Ord for S3ChecksumAlgorithm
source§fn cmp(&self, other: &S3ChecksumAlgorithm) -> Ordering
fn cmp(&self, other: &S3ChecksumAlgorithm) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<S3ChecksumAlgorithm> for S3ChecksumAlgorithm
impl PartialEq<S3ChecksumAlgorithm> for S3ChecksumAlgorithm
source§fn eq(&self, other: &S3ChecksumAlgorithm) -> bool
fn eq(&self, other: &S3ChecksumAlgorithm) -> bool
source§impl PartialOrd<S3ChecksumAlgorithm> for S3ChecksumAlgorithm
impl PartialOrd<S3ChecksumAlgorithm> for S3ChecksumAlgorithm
source§fn partial_cmp(&self, other: &S3ChecksumAlgorithm) -> Option<Ordering>
fn partial_cmp(&self, other: &S3ChecksumAlgorithm) -> 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 S3ChecksumAlgorithm
impl StructuralEq for S3ChecksumAlgorithm
impl StructuralPartialEq for S3ChecksumAlgorithm
Auto Trait Implementations§
impl RefUnwindSafe for S3ChecksumAlgorithm
impl Send for S3ChecksumAlgorithm
impl Sync for S3ChecksumAlgorithm
impl Unpin for S3ChecksumAlgorithm
impl UnwindSafe for S3ChecksumAlgorithm
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.