Enum aws_sdk_s3::model::ObjectAttributes
source · #[non_exhaustive]
pub enum ObjectAttributes {
Checksum,
Etag,
ObjectParts,
ObjectSize,
StorageClass,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against ObjectAttributes
, 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 objectattributes = unimplemented!();
match objectattributes {
ObjectAttributes::Checksum => { /* ... */ },
ObjectAttributes::Etag => { /* ... */ },
ObjectAttributes::ObjectParts => { /* ... */ },
ObjectAttributes::ObjectSize => { /* ... */ },
ObjectAttributes::StorageClass => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when objectattributes
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant ObjectAttributes::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
ObjectAttributes::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 ObjectAttributes::NewFeature
is defined.
Specifically, when objectattributes
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on ObjectAttributes::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
Checksum
Etag
ObjectParts
ObjectSize
StorageClass
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl ObjectAttributes
impl ObjectAttributes
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
2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904
pub fn add_headers_get_object_attributes(
input: &crate::input::GetObjectAttributesInput,
mut builder: http::request::Builder,
) -> std::result::Result<http::request::Builder, aws_smithy_http::operation::error::BuildError> {
if input.max_parts != 0 {
let mut encoder = aws_smithy_types::primitive::Encoder::from(input.max_parts);
let formatted_276 = encoder.encode();
if !formatted_276.is_empty() {
let header_value = formatted_276;
let header_value =
http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
aws_smithy_http::operation::error::BuildError::invalid_field(
"max_parts",
format!(
"`{}` cannot be used as a header value: {}",
&header_value, err
),
)
})?;
builder = builder.header("x-amz-max-parts", header_value);
}
}
if let Some(inner_277) = &input.part_number_marker {
let formatted_278 = inner_277.as_str();
if !formatted_278.is_empty() {
let header_value = formatted_278;
let header_value =
http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
aws_smithy_http::operation::error::BuildError::invalid_field(
"part_number_marker",
format!(
"`{}` cannot be used as a header value: {}",
&header_value, err
),
)
})?;
builder = builder.header("x-amz-part-number-marker", header_value);
}
}
if let Some(inner_279) = &input.sse_customer_algorithm {
let formatted_280 = inner_279.as_str();
if !formatted_280.is_empty() {
let header_value = formatted_280;
let header_value =
http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
aws_smithy_http::operation::error::BuildError::invalid_field(
"sse_customer_algorithm",
format!(
"`{}` cannot be used as a header value: {}",
&header_value, err
),
)
})?;
builder = builder.header(
"x-amz-server-side-encryption-customer-algorithm",
header_value,
);
}
}
if let Some(inner_281) = &input.sse_customer_key {
let formatted_282 = inner_281.as_str();
if !formatted_282.is_empty() {
let header_value = formatted_282;
let header_value =
http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
aws_smithy_http::operation::error::BuildError::invalid_field(
"sse_customer_key",
format!(
"`{}` cannot be used as a header value: {}",
&"*** Sensitive Data Redacted ***", err
),
)
})?;
builder = builder.header("x-amz-server-side-encryption-customer-key", header_value);
}
}
if let Some(inner_283) = &input.sse_customer_key_md5 {
let formatted_284 = inner_283.as_str();
if !formatted_284.is_empty() {
let header_value = formatted_284;
let header_value =
http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
aws_smithy_http::operation::error::BuildError::invalid_field(
"sse_customer_key_md5",
format!(
"`{}` cannot be used as a header value: {}",
&header_value, err
),
)
})?;
builder = builder.header(
"x-amz-server-side-encryption-customer-key-MD5",
header_value,
);
}
}
if let Some(inner_285) = &input.request_payer {
let formatted_286 = inner_285.as_str();
if !formatted_286.is_empty() {
let header_value = formatted_286;
let header_value =
http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
aws_smithy_http::operation::error::BuildError::invalid_field(
"request_payer",
format!(
"`{}` cannot be used as a header value: {}",
&header_value, err
),
)
})?;
builder = builder.header("x-amz-request-payer", header_value);
}
}
if let Some(inner_287) = &input.expected_bucket_owner {
let formatted_288 = inner_287.as_str();
if !formatted_288.is_empty() {
let header_value = formatted_288;
let header_value =
http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
aws_smithy_http::operation::error::BuildError::invalid_field(
"expected_bucket_owner",
format!(
"`{}` cannot be used as a header value: {}",
&header_value, err
),
)
})?;
builder = builder.header("x-amz-expected-bucket-owner", header_value);
}
}
if let Some(inner_289) = &input.object_attributes {
for inner_290 in inner_289 {
let formatted_291 = aws_smithy_http::header::quote_header_value(inner_290.as_str());
if !formatted_291.is_empty() {
let header_value = formatted_291;
let header_value =
http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
aws_smithy_http::operation::error::BuildError::invalid_field(
"object_attributes",
format!(
"`{}` cannot be used as a header value: {}",
&header_value, err
),
)
})?;
builder = builder.header("x-amz-object-attributes", header_value);
}
}
}
Ok(builder)
}
Trait Implementations§
source§impl AsRef<str> for ObjectAttributes
impl AsRef<str> for ObjectAttributes
source§impl Clone for ObjectAttributes
impl Clone for ObjectAttributes
source§fn clone(&self) -> ObjectAttributes
fn clone(&self) -> ObjectAttributes
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ObjectAttributes
impl Debug for ObjectAttributes
source§impl From<&str> for ObjectAttributes
impl From<&str> for ObjectAttributes
source§impl FromStr for ObjectAttributes
impl FromStr for ObjectAttributes
source§impl Hash for ObjectAttributes
impl Hash for ObjectAttributes
source§impl Ord for ObjectAttributes
impl Ord for ObjectAttributes
source§fn cmp(&self, other: &ObjectAttributes) -> Ordering
fn cmp(&self, other: &ObjectAttributes) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<ObjectAttributes> for ObjectAttributes
impl PartialEq<ObjectAttributes> for ObjectAttributes
source§fn eq(&self, other: &ObjectAttributes) -> bool
fn eq(&self, other: &ObjectAttributes) -> bool
source§impl PartialOrd<ObjectAttributes> for ObjectAttributes
impl PartialOrd<ObjectAttributes> for ObjectAttributes
source§fn partial_cmp(&self, other: &ObjectAttributes) -> Option<Ordering>
fn partial_cmp(&self, other: &ObjectAttributes) -> 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 ObjectAttributes
impl StructuralEq for ObjectAttributes
impl StructuralPartialEq for ObjectAttributes
Auto Trait Implementations§
impl RefUnwindSafe for ObjectAttributes
impl Send for ObjectAttributes
impl Sync for ObjectAttributes
impl Unpin for ObjectAttributes
impl UnwindSafe for ObjectAttributes
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.