Enum aws_sdk_cloudformation::model::VersionBump
source · #[non_exhaustive]
pub enum VersionBump {
Major,
Minor,
Unknown(UnknownVariantValue),
}Expand description
When writing a match expression against VersionBump, 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 versionbump = unimplemented!();
match versionbump {
VersionBump::Major => { /* ... */ },
VersionBump::Minor => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when versionbump represents
NewFeature, the execution path will lead to the second last match arm,
even though the enum does not contain a variant VersionBump::NewFeature
in the current version of SDK. The reason is that the variable other,
created by the @ operator, is bound to
VersionBump::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 VersionBump::NewFeature is defined.
Specifically, when versionbump represents NewFeature,
the execution path will hit the second last match arm as before by virtue of
calling as_str on VersionBump::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
Major
Minor
Unknown(UnknownVariantValue)
Unknown contains new variants that have been added since this code was generated.
Implementations§
source§impl VersionBump
impl VersionBump
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
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
pub fn serialize_operation_crate_operation_activate_type(
input: &crate::input::ActivateTypeInput,
) -> 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, "ActivateType", "2010-05-15");
#[allow(unused_mut)]
let mut scope_1 = writer.prefix("Type");
if let Some(var_2) = &input.r#type {
scope_1.string(var_2.as_str());
}
#[allow(unused_mut)]
let mut scope_3 = writer.prefix("PublicTypeArn");
if let Some(var_4) = &input.public_type_arn {
scope_3.string(var_4);
}
#[allow(unused_mut)]
let mut scope_5 = writer.prefix("PublisherId");
if let Some(var_6) = &input.publisher_id {
scope_5.string(var_6);
}
#[allow(unused_mut)]
let mut scope_7 = writer.prefix("TypeName");
if let Some(var_8) = &input.type_name {
scope_7.string(var_8);
}
#[allow(unused_mut)]
let mut scope_9 = writer.prefix("TypeNameAlias");
if let Some(var_10) = &input.type_name_alias {
scope_9.string(var_10);
}
#[allow(unused_mut)]
let mut scope_11 = writer.prefix("AutoUpdate");
if let Some(var_12) = &input.auto_update {
scope_11.boolean(*var_12);
}
#[allow(unused_mut)]
let mut scope_13 = writer.prefix("LoggingConfig");
if let Some(var_14) = &input.logging_config {
crate::query_ser::serialize_structure_crate_model_logging_config(scope_13, var_14)?;
}
#[allow(unused_mut)]
let mut scope_15 = writer.prefix("ExecutionRoleArn");
if let Some(var_16) = &input.execution_role_arn {
scope_15.string(var_16);
}
#[allow(unused_mut)]
let mut scope_17 = writer.prefix("VersionBump");
if let Some(var_18) = &input.version_bump {
scope_17.string(var_18.as_str());
}
#[allow(unused_mut)]
let mut scope_19 = writer.prefix("MajorVersion");
if let Some(var_20) = &input.major_version {
scope_19.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_20).into()),
);
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}Trait Implementations§
source§impl AsRef<str> for VersionBump
impl AsRef<str> for VersionBump
source§impl Clone for VersionBump
impl Clone for VersionBump
source§fn clone(&self) -> VersionBump
fn clone(&self) -> VersionBump
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for VersionBump
impl Debug for VersionBump
source§impl From<&str> for VersionBump
impl From<&str> for VersionBump
source§impl FromStr for VersionBump
impl FromStr for VersionBump
source§impl Hash for VersionBump
impl Hash for VersionBump
source§impl Ord for VersionBump
impl Ord for VersionBump
source§fn cmp(&self, other: &VersionBump) -> Ordering
fn cmp(&self, other: &VersionBump) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<VersionBump> for VersionBump
impl PartialEq<VersionBump> for VersionBump
source§fn eq(&self, other: &VersionBump) -> bool
fn eq(&self, other: &VersionBump) -> bool
source§impl PartialOrd<VersionBump> for VersionBump
impl PartialOrd<VersionBump> for VersionBump
source§fn partial_cmp(&self, other: &VersionBump) -> Option<Ordering>
fn partial_cmp(&self, other: &VersionBump) -> 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 VersionBump
impl StructuralEq for VersionBump
impl StructuralPartialEq for VersionBump
Auto Trait Implementations§
impl RefUnwindSafe for VersionBump
impl Send for VersionBump
impl Sync for VersionBump
impl Unpin for VersionBump
impl UnwindSafe for VersionBump
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.