Enum aws_sdk_s3::model::ObjectOwnership
source · #[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
BucketOwnerEnforced
BucketOwnerPreferred
ObjectWriter
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl ObjectOwnership
impl ObjectOwnership
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
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(())
}
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)
}
Trait Implementations§
source§impl AsRef<str> for ObjectOwnership
impl AsRef<str> for ObjectOwnership
source§impl Clone for ObjectOwnership
impl Clone for ObjectOwnership
source§fn clone(&self) -> ObjectOwnership
fn clone(&self) -> ObjectOwnership
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ObjectOwnership
impl Debug for ObjectOwnership
source§impl From<&str> for ObjectOwnership
impl From<&str> for ObjectOwnership
source§impl FromStr for ObjectOwnership
impl FromStr for ObjectOwnership
source§impl Hash for ObjectOwnership
impl Hash for ObjectOwnership
source§impl Ord for ObjectOwnership
impl Ord for ObjectOwnership
source§fn cmp(&self, other: &ObjectOwnership) -> Ordering
fn cmp(&self, other: &ObjectOwnership) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<ObjectOwnership> for ObjectOwnership
impl PartialEq<ObjectOwnership> for ObjectOwnership
source§fn eq(&self, other: &ObjectOwnership) -> bool
fn eq(&self, other: &ObjectOwnership) -> bool
source§impl PartialOrd<ObjectOwnership> for ObjectOwnership
impl PartialOrd<ObjectOwnership> for ObjectOwnership
source§fn partial_cmp(&self, other: &ObjectOwnership) -> Option<Ordering>
fn partial_cmp(&self, other: &ObjectOwnership) -> 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 ObjectOwnership
impl StructuralEq for ObjectOwnership
impl StructuralPartialEq for ObjectOwnership
Auto Trait Implementations§
impl RefUnwindSafe for ObjectOwnership
impl Send for ObjectOwnership
impl Sync for ObjectOwnership
impl Unpin for ObjectOwnership
impl UnwindSafe for ObjectOwnership
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.