Enum aws_sdk_s3::model::Type
source · #[non_exhaustive]
pub enum Type {
AmazonCustomerByEmail,
CanonicalUser,
Group,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against Type
, 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 type = unimplemented!();
match type {
Type::AmazonCustomerByEmail => { /* ... */ },
Type::CanonicalUser => { /* ... */ },
Type::Group => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when type
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant Type::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
Type::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 Type::NewFeature
is defined.
Specifically, when type
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on Type::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
AmazonCustomerByEmail
CanonicalUser
Group
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl Type
impl Type
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
1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998
pub fn serialize_structure_crate_model_grantee(
input: &crate::model::Grantee,
writer: aws_smithy_xml::encode::ElWriter,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
let mut writer = writer;
if let Some(var_175) = &input.r#type {
writer.write_attribute("xsi:type", var_175.as_str());
}
#[allow(unused_mut)]
let mut scope = writer.finish();
if let Some(var_176) = &input.display_name {
let mut inner_writer = scope.start_el("DisplayName").finish();
inner_writer.data(var_176.as_str());
}
if let Some(var_177) = &input.email_address {
let mut inner_writer = scope.start_el("EmailAddress").finish();
inner_writer.data(var_177.as_str());
}
if let Some(var_178) = &input.id {
let mut inner_writer = scope.start_el("ID").finish();
inner_writer.data(var_178.as_str());
}
if let Some(var_179) = &input.uri {
let mut inner_writer = scope.start_el("URI").finish();
inner_writer.data(var_179.as_str());
}
scope.finish();
Ok(())
}
Trait Implementations§
source§impl Ord for Type
impl Ord for Type
source§impl PartialOrd<Type> for Type
impl PartialOrd<Type> for Type
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 Type
impl StructuralEq for Type
impl StructuralPartialEq for Type
Auto Trait Implementations§
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnwindSafe for Type
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.