Enum aws_sdk_cloudfront::model::FunctionStage
source · #[non_exhaustive]
pub enum FunctionStage {
Development,
Live,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against FunctionStage
, 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 functionstage = unimplemented!();
match functionstage {
FunctionStage::Development => { /* ... */ },
FunctionStage::Live => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when functionstage
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant FunctionStage::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
FunctionStage::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 FunctionStage::NewFeature
is defined.
Specifically, when functionstage
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on FunctionStage::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
Development
Live
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl FunctionStage
impl FunctionStage
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
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
pub fn serialize_structure_crate_input_test_function_input(
input: &crate::input::TestFunctionInput,
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_18) = &input.event_object {
let mut inner_writer = scope.start_el("EventObject").finish();
inner_writer.data(aws_smithy_types::base64::encode(var_18.as_ref()).as_ref());
}
if let Some(var_19) = &input.stage {
let mut inner_writer = scope.start_el("Stage").finish();
inner_writer.data(var_19.as_str());
}
scope.finish();
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for FunctionStage
impl AsRef<str> for FunctionStage
source§impl Clone for FunctionStage
impl Clone for FunctionStage
source§fn clone(&self) -> FunctionStage
fn clone(&self) -> FunctionStage
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FunctionStage
impl Debug for FunctionStage
source§impl From<&str> for FunctionStage
impl From<&str> for FunctionStage
source§impl FromStr for FunctionStage
impl FromStr for FunctionStage
source§impl Hash for FunctionStage
impl Hash for FunctionStage
source§impl Ord for FunctionStage
impl Ord for FunctionStage
source§fn cmp(&self, other: &FunctionStage) -> Ordering
fn cmp(&self, other: &FunctionStage) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<FunctionStage> for FunctionStage
impl PartialEq<FunctionStage> for FunctionStage
source§fn eq(&self, other: &FunctionStage) -> bool
fn eq(&self, other: &FunctionStage) -> bool
source§impl PartialOrd<FunctionStage> for FunctionStage
impl PartialOrd<FunctionStage> for FunctionStage
source§fn partial_cmp(&self, other: &FunctionStage) -> Option<Ordering>
fn partial_cmp(&self, other: &FunctionStage) -> 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 FunctionStage
impl StructuralEq for FunctionStage
impl StructuralPartialEq for FunctionStage
Auto Trait Implementations§
impl RefUnwindSafe for FunctionStage
impl Send for FunctionStage
impl Sync for FunctionStage
impl Unpin for FunctionStage
impl UnwindSafe for FunctionStage
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.