#[non_exhaustive]
pub enum ObjectOwnership {
    BucketOwnerEnforced,
    BucketOwnerPreferred,
    ObjectWriter,
    Unknown(UnknownVariantValue),
}
Expand description

When writing a match expression against ObjectOwnership, 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 objectownership = unimplemented!();
match objectownership {
    ObjectOwnership::BucketOwnerEnforced => { /* ... */ },
    ObjectOwnership::BucketOwnerPreferred => { /* ... */ },
    ObjectOwnership::ObjectWriter => { /* ... */ },
    other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
    _ => { /* ... */ },
}

The above code demonstrates that when objectownership represents NewFeature, the execution path will lead to the second last match arm, even though the enum does not contain a variant ObjectOwnership::NewFeature in the current version of SDK. The reason is that the variable other, created by the @ operator, is bound to ObjectOwnership::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 ObjectOwnership::NewFeature is defined. Specifically, when objectownership represents NewFeature, the execution path will hit the second last match arm as before by virtue of calling as_str on ObjectOwnership::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.

The container element for object ownership for a bucket's ownership controls.

BucketOwnerPreferred - Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control canned ACL.

ObjectWriter - The uploading account will own the object if the object is uploaded with the bucket-owner-full-control canned ACL.

BucketOwnerEnforced - Access control lists (ACLs) are disabled and no longer affect permissions. The bucket owner automatically owns and has full control over every object in the bucket. The bucket only accepts PUT requests that don't specify an ACL or bucket owner full control ACLs, such as the bucket-owner-full-control canned ACL or an equivalent form of this ACL expressed in the XML format.

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.
§

BucketOwnerEnforced

§

BucketOwnerPreferred

§

ObjectWriter

§

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 8475)
8474
8475
8476
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/xml_ser.rs (line 1660)
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
pub fn serialize_structure_crate_model_ownership_controls_rule(
    input: &crate::model::OwnershipControlsRule,
    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_138) = &input.object_ownership {
        let mut inner_writer = scope.start_el("ObjectOwnership").finish();
        inner_writer.data(var_138.as_str());
    }
    scope.finish();
    Ok(())
}
src/http_serde.rs (line 1031)
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
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
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
pub fn add_headers_create_bucket(
    input: &crate::input::CreateBucketInput,
    mut builder: http::request::Builder,
) -> std::result::Result<http::request::Builder, aws_smithy_http::operation::error::BuildError> {
    if let Some(inner_99) = &input.acl {
        let formatted_100 = inner_99.as_str();
        if !formatted_100.is_empty() {
            let header_value = formatted_100;
            let header_value =
                http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
                    aws_smithy_http::operation::error::BuildError::invalid_field(
                        "acl",
                        format!(
                            "`{}` cannot be used as a header value: {}",
                            &header_value, err
                        ),
                    )
                })?;
            builder = builder.header("x-amz-acl", header_value);
        }
    }
    if let Some(inner_101) = &input.grant_full_control {
        let formatted_102 = inner_101.as_str();
        if !formatted_102.is_empty() {
            let header_value = formatted_102;
            let header_value =
                http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
                    aws_smithy_http::operation::error::BuildError::invalid_field(
                        "grant_full_control",
                        format!(
                            "`{}` cannot be used as a header value: {}",
                            &header_value, err
                        ),
                    )
                })?;
            builder = builder.header("x-amz-grant-full-control", header_value);
        }
    }
    if let Some(inner_103) = &input.grant_read {
        let formatted_104 = inner_103.as_str();
        if !formatted_104.is_empty() {
            let header_value = formatted_104;
            let header_value =
                http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
                    aws_smithy_http::operation::error::BuildError::invalid_field(
                        "grant_read",
                        format!(
                            "`{}` cannot be used as a header value: {}",
                            &header_value, err
                        ),
                    )
                })?;
            builder = builder.header("x-amz-grant-read", header_value);
        }
    }
    if let Some(inner_105) = &input.grant_read_acp {
        let formatted_106 = inner_105.as_str();
        if !formatted_106.is_empty() {
            let header_value = formatted_106;
            let header_value =
                http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
                    aws_smithy_http::operation::error::BuildError::invalid_field(
                        "grant_read_acp",
                        format!(
                            "`{}` cannot be used as a header value: {}",
                            &header_value, err
                        ),
                    )
                })?;
            builder = builder.header("x-amz-grant-read-acp", header_value);
        }
    }
    if let Some(inner_107) = &input.grant_write {
        let formatted_108 = inner_107.as_str();
        if !formatted_108.is_empty() {
            let header_value = formatted_108;
            let header_value =
                http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
                    aws_smithy_http::operation::error::BuildError::invalid_field(
                        "grant_write",
                        format!(
                            "`{}` cannot be used as a header value: {}",
                            &header_value, err
                        ),
                    )
                })?;
            builder = builder.header("x-amz-grant-write", header_value);
        }
    }
    if let Some(inner_109) = &input.grant_write_acp {
        let formatted_110 = inner_109.as_str();
        if !formatted_110.is_empty() {
            let header_value = formatted_110;
            let header_value =
                http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
                    aws_smithy_http::operation::error::BuildError::invalid_field(
                        "grant_write_acp",
                        format!(
                            "`{}` cannot be used as a header value: {}",
                            &header_value, err
                        ),
                    )
                })?;
            builder = builder.header("x-amz-grant-write-acp", header_value);
        }
    }
    if input.object_lock_enabled_for_bucket {
        let mut encoder =
            aws_smithy_types::primitive::Encoder::from(input.object_lock_enabled_for_bucket);
        let formatted_111 = encoder.encode();
        if !formatted_111.is_empty() {
            let header_value = formatted_111;
            let header_value =
                http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
                    aws_smithy_http::operation::error::BuildError::invalid_field(
                        "object_lock_enabled_for_bucket",
                        format!(
                            "`{}` cannot be used as a header value: {}",
                            &header_value, err
                        ),
                    )
                })?;
            builder = builder.header("x-amz-bucket-object-lock-enabled", header_value);
        }
    }
    if let Some(inner_112) = &input.object_ownership {
        let formatted_113 = inner_112.as_str();
        if !formatted_113.is_empty() {
            let header_value = formatted_113;
            let header_value =
                http::header::HeaderValue::try_from(&*header_value).map_err(|err| {
                    aws_smithy_http::operation::error::BuildError::invalid_field(
                        "object_ownership",
                        format!(
                            "`{}` cannot be used as a header value: {}",
                            &header_value, err
                        ),
                    )
                })?;
            builder = builder.header("x-amz-object-ownership", 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