#[non_exhaustive]
pub enum InputCompressionType {
Gzip,
None,
Zstd,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against InputCompressionType
, 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 inputcompressiontype = unimplemented!();
match inputcompressiontype {
InputCompressionType::Gzip => { /* ... */ },
InputCompressionType::None => { /* ... */ },
InputCompressionType::Zstd => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when inputcompressiontype
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant InputCompressionType::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
InputCompressionType::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 InputCompressionType::NewFeature
is defined.
Specifically, when inputcompressiontype
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on InputCompressionType::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
Gzip
None
Zstd
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl InputCompressionType
impl InputCompressionType
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
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686
pub fn serialize_structure_crate_input_import_table_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::ImportTableInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_140) = &input.client_token {
object.key("ClientToken").string(var_140.as_str());
}
if let Some(var_141) = &input.s3_bucket_source {
#[allow(unused_mut)]
let mut object_142 = object.key("S3BucketSource").start_object();
crate::json_ser::serialize_structure_crate_model_s3_bucket_source(
&mut object_142,
var_141,
)?;
object_142.finish();
}
if let Some(var_143) = &input.input_format {
object.key("InputFormat").string(var_143.as_str());
}
if let Some(var_144) = &input.input_format_options {
#[allow(unused_mut)]
let mut object_145 = object.key("InputFormatOptions").start_object();
crate::json_ser::serialize_structure_crate_model_input_format_options(
&mut object_145,
var_144,
)?;
object_145.finish();
}
if let Some(var_146) = &input.input_compression_type {
object.key("InputCompressionType").string(var_146.as_str());
}
if let Some(var_147) = &input.table_creation_parameters {
#[allow(unused_mut)]
let mut object_148 = object.key("TableCreationParameters").start_object();
crate::json_ser::serialize_structure_crate_model_table_creation_parameters(
&mut object_148,
var_147,
)?;
object_148.finish();
}
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for InputCompressionType
impl AsRef<str> for InputCompressionType
source§impl Clone for InputCompressionType
impl Clone for InputCompressionType
source§fn clone(&self) -> InputCompressionType
fn clone(&self) -> InputCompressionType
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for InputCompressionType
impl Debug for InputCompressionType
source§impl From<&str> for InputCompressionType
impl From<&str> for InputCompressionType
source§impl FromStr for InputCompressionType
impl FromStr for InputCompressionType
source§impl Hash for InputCompressionType
impl Hash for InputCompressionType
source§impl Ord for InputCompressionType
impl Ord for InputCompressionType
source§fn cmp(&self, other: &InputCompressionType) -> Ordering
fn cmp(&self, other: &InputCompressionType) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<InputCompressionType> for InputCompressionType
impl PartialEq<InputCompressionType> for InputCompressionType
source§fn eq(&self, other: &InputCompressionType) -> bool
fn eq(&self, other: &InputCompressionType) -> bool
source§impl PartialOrd<InputCompressionType> for InputCompressionType
impl PartialOrd<InputCompressionType> for InputCompressionType
source§fn partial_cmp(&self, other: &InputCompressionType) -> Option<Ordering>
fn partial_cmp(&self, other: &InputCompressionType) -> 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 InputCompressionType
impl StructuralEq for InputCompressionType
impl StructuralPartialEq for InputCompressionType
Auto Trait Implementations§
impl RefUnwindSafe for InputCompressionType
impl Send for InputCompressionType
impl Sync for InputCompressionType
impl Unpin for InputCompressionType
impl UnwindSafe for InputCompressionType
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.