#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Checksum

§

Etag

§

ObjectParts

§

ObjectSize

§

StorageClass

§

Unknown(UnknownVariantValue)

Unknown contains new variants that have been added since this code was generated.

Implementations§

Returns the &str value of the enum member.

Examples found in repository?
src/model.rs (line 16234)
16233
16234
16235
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/http_serde.rs (line 2886)
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)
}

Returns all the &str values of the enum members.

Trait Implementations§

Converts this type into a shared reference of the (usually inferred) input type.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more