Enum aws_sdk_cloudformation::model::Visibility
source · #[non_exhaustive]
pub enum Visibility {
Private,
Public,
Unknown(UnknownVariantValue),
}Expand description
When writing a match expression against Visibility, 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 visibility = unimplemented!();
match visibility {
Visibility::Private => { /* ... */ },
Visibility::Public => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when visibility represents
NewFeature, the execution path will lead to the second last match arm,
even though the enum does not contain a variant Visibility::NewFeature
in the current version of SDK. The reason is that the variable other,
created by the @ operator, is bound to
Visibility::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 Visibility::NewFeature is defined.
Specifically, when visibility represents NewFeature,
the execution path will hit the second last match arm as before by virtue of
calling as_str on Visibility::NewFeature also yielding "NewFeature".
Explicitly matching on the Unknown variant should
be avoided for two reasons:
- The inner data
UnknownVariantValueis 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
Private
Public
Unknown(UnknownVariantValue)
Unknown contains new variants that have been added since this code was generated.
Implementations§
source§impl Visibility
impl Visibility
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
1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785
pub fn serialize_operation_crate_operation_list_types(
input: &crate::input::ListTypesInput,
) -> Result<aws_smithy_http::body::SdkBody, aws_smithy_http::operation::error::SerializationError> {
let mut out = String::new();
#[allow(unused_mut)]
let mut writer = aws_smithy_query::QueryWriter::new(&mut out, "ListTypes", "2010-05-15");
#[allow(unused_mut)]
let mut scope_491 = writer.prefix("Visibility");
if let Some(var_492) = &input.visibility {
scope_491.string(var_492.as_str());
}
#[allow(unused_mut)]
let mut scope_493 = writer.prefix("ProvisioningType");
if let Some(var_494) = &input.provisioning_type {
scope_493.string(var_494.as_str());
}
#[allow(unused_mut)]
let mut scope_495 = writer.prefix("DeprecatedStatus");
if let Some(var_496) = &input.deprecated_status {
scope_495.string(var_496.as_str());
}
#[allow(unused_mut)]
let mut scope_497 = writer.prefix("Type");
if let Some(var_498) = &input.r#type {
scope_497.string(var_498.as_str());
}
#[allow(unused_mut)]
let mut scope_499 = writer.prefix("Filters");
if let Some(var_500) = &input.filters {
crate::query_ser::serialize_structure_crate_model_type_filters(scope_499, var_500)?;
}
#[allow(unused_mut)]
let mut scope_501 = writer.prefix("MaxResults");
if let Some(var_502) = &input.max_results {
scope_501.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_502).into()),
);
}
#[allow(unused_mut)]
let mut scope_503 = writer.prefix("NextToken");
if let Some(var_504) = &input.next_token {
scope_503.string(var_504);
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}Trait Implementations§
source§impl AsRef<str> for Visibility
impl AsRef<str> for Visibility
source§impl Clone for Visibility
impl Clone for Visibility
source§fn clone(&self) -> Visibility
fn clone(&self) -> Visibility
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for Visibility
impl Debug for Visibility
source§impl From<&str> for Visibility
impl From<&str> for Visibility
source§impl FromStr for Visibility
impl FromStr for Visibility
source§impl Hash for Visibility
impl Hash for Visibility
source§impl Ord for Visibility
impl Ord for Visibility
source§fn cmp(&self, other: &Visibility) -> Ordering
fn cmp(&self, other: &Visibility) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<Visibility> for Visibility
impl PartialEq<Visibility> for Visibility
source§fn eq(&self, other: &Visibility) -> bool
fn eq(&self, other: &Visibility) -> bool
source§impl PartialOrd<Visibility> for Visibility
impl PartialOrd<Visibility> for Visibility
source§fn partial_cmp(&self, other: &Visibility) -> Option<Ordering>
fn partial_cmp(&self, other: &Visibility) -> 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 Visibility
impl StructuralEq for Visibility
impl StructuralPartialEq for Visibility
Auto Trait Implementations§
impl RefUnwindSafe for Visibility
impl Send for Visibility
impl Sync for Visibility
impl Unpin for Visibility
impl UnwindSafe for Visibility
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.