#[non_exhaustive]
pub enum FileFormat {
Csv,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against FileFormat
, 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 fileformat = unimplemented!();
match fileformat {
FileFormat::Csv => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when fileformat
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant FileFormat::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
FileFormat::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 FileFormat::NewFeature
is defined.
Specifically, when fileformat
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on FileFormat::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
Csv
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl FileFormat
impl FileFormat
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
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
pub fn serialize_structure_crate_input_export_auto_scaling_group_recommendations_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::ExportAutoScalingGroupRecommendationsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_16) = &input.account_ids {
let mut array_17 = object.key("accountIds").start_array();
for item_18 in var_16 {
{
array_17.value().string(item_18.as_str());
}
}
array_17.finish();
}
if let Some(var_19) = &input.filters {
let mut array_20 = object.key("filters").start_array();
for item_21 in var_19 {
{
#[allow(unused_mut)]
let mut object_22 = array_20.value().start_object();
crate::json_ser::serialize_structure_crate_model_filter(&mut object_22, item_21)?;
object_22.finish();
}
}
array_20.finish();
}
if let Some(var_23) = &input.fields_to_export {
let mut array_24 = object.key("fieldsToExport").start_array();
for item_25 in var_23 {
{
array_24.value().string(item_25.as_str());
}
}
array_24.finish();
}
if let Some(var_26) = &input.s3_destination_config {
#[allow(unused_mut)]
let mut object_27 = object.key("s3DestinationConfig").start_object();
crate::json_ser::serialize_structure_crate_model_s3_destination_config(
&mut object_27,
var_26,
)?;
object_27.finish();
}
if let Some(var_28) = &input.file_format {
object.key("fileFormat").string(var_28.as_str());
}
if input.include_member_accounts {
object
.key("includeMemberAccounts")
.boolean(input.include_member_accounts);
}
if let Some(var_29) = &input.recommendation_preferences {
#[allow(unused_mut)]
let mut object_30 = object.key("recommendationPreferences").start_object();
crate::json_ser::serialize_structure_crate_model_recommendation_preferences(
&mut object_30,
var_29,
)?;
object_30.finish();
}
Ok(())
}
pub fn serialize_structure_crate_input_export_ebs_volume_recommendations_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::ExportEbsVolumeRecommendationsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_31) = &input.account_ids {
let mut array_32 = object.key("accountIds").start_array();
for item_33 in var_31 {
{
array_32.value().string(item_33.as_str());
}
}
array_32.finish();
}
if let Some(var_34) = &input.filters {
let mut array_35 = object.key("filters").start_array();
for item_36 in var_34 {
{
#[allow(unused_mut)]
let mut object_37 = array_35.value().start_object();
crate::json_ser::serialize_structure_crate_model_ebs_filter(
&mut object_37,
item_36,
)?;
object_37.finish();
}
}
array_35.finish();
}
if let Some(var_38) = &input.fields_to_export {
let mut array_39 = object.key("fieldsToExport").start_array();
for item_40 in var_38 {
{
array_39.value().string(item_40.as_str());
}
}
array_39.finish();
}
if let Some(var_41) = &input.s3_destination_config {
#[allow(unused_mut)]
let mut object_42 = object.key("s3DestinationConfig").start_object();
crate::json_ser::serialize_structure_crate_model_s3_destination_config(
&mut object_42,
var_41,
)?;
object_42.finish();
}
if let Some(var_43) = &input.file_format {
object.key("fileFormat").string(var_43.as_str());
}
if input.include_member_accounts {
object
.key("includeMemberAccounts")
.boolean(input.include_member_accounts);
}
Ok(())
}
pub fn serialize_structure_crate_input_export_ec2_instance_recommendations_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::ExportEc2InstanceRecommendationsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_44) = &input.account_ids {
let mut array_45 = object.key("accountIds").start_array();
for item_46 in var_44 {
{
array_45.value().string(item_46.as_str());
}
}
array_45.finish();
}
if let Some(var_47) = &input.filters {
let mut array_48 = object.key("filters").start_array();
for item_49 in var_47 {
{
#[allow(unused_mut)]
let mut object_50 = array_48.value().start_object();
crate::json_ser::serialize_structure_crate_model_filter(&mut object_50, item_49)?;
object_50.finish();
}
}
array_48.finish();
}
if let Some(var_51) = &input.fields_to_export {
let mut array_52 = object.key("fieldsToExport").start_array();
for item_53 in var_51 {
{
array_52.value().string(item_53.as_str());
}
}
array_52.finish();
}
if let Some(var_54) = &input.s3_destination_config {
#[allow(unused_mut)]
let mut object_55 = object.key("s3DestinationConfig").start_object();
crate::json_ser::serialize_structure_crate_model_s3_destination_config(
&mut object_55,
var_54,
)?;
object_55.finish();
}
if let Some(var_56) = &input.file_format {
object.key("fileFormat").string(var_56.as_str());
}
if input.include_member_accounts {
object
.key("includeMemberAccounts")
.boolean(input.include_member_accounts);
}
if let Some(var_57) = &input.recommendation_preferences {
#[allow(unused_mut)]
let mut object_58 = object.key("recommendationPreferences").start_object();
crate::json_ser::serialize_structure_crate_model_recommendation_preferences(
&mut object_58,
var_57,
)?;
object_58.finish();
}
Ok(())
}
pub fn serialize_structure_crate_input_export_lambda_function_recommendations_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::ExportLambdaFunctionRecommendationsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_59) = &input.account_ids {
let mut array_60 = object.key("accountIds").start_array();
for item_61 in var_59 {
{
array_60.value().string(item_61.as_str());
}
}
array_60.finish();
}
if let Some(var_62) = &input.filters {
let mut array_63 = object.key("filters").start_array();
for item_64 in var_62 {
{
#[allow(unused_mut)]
let mut object_65 = array_63.value().start_object();
crate::json_ser::serialize_structure_crate_model_lambda_function_recommendation_filter(&mut object_65, item_64)?;
object_65.finish();
}
}
array_63.finish();
}
if let Some(var_66) = &input.fields_to_export {
let mut array_67 = object.key("fieldsToExport").start_array();
for item_68 in var_66 {
{
array_67.value().string(item_68.as_str());
}
}
array_67.finish();
}
if let Some(var_69) = &input.s3_destination_config {
#[allow(unused_mut)]
let mut object_70 = object.key("s3DestinationConfig").start_object();
crate::json_ser::serialize_structure_crate_model_s3_destination_config(
&mut object_70,
var_69,
)?;
object_70.finish();
}
if let Some(var_71) = &input.file_format {
object.key("fileFormat").string(var_71.as_str());
}
if input.include_member_accounts {
object
.key("includeMemberAccounts")
.boolean(input.include_member_accounts);
}
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for FileFormat
impl AsRef<str> for FileFormat
source§impl Clone for FileFormat
impl Clone for FileFormat
source§fn clone(&self) -> FileFormat
fn clone(&self) -> FileFormat
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FileFormat
impl Debug for FileFormat
source§impl From<&str> for FileFormat
impl From<&str> for FileFormat
source§impl FromStr for FileFormat
impl FromStr for FileFormat
source§impl Hash for FileFormat
impl Hash for FileFormat
source§impl Ord for FileFormat
impl Ord for FileFormat
source§fn cmp(&self, other: &FileFormat) -> Ordering
fn cmp(&self, other: &FileFormat) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<FileFormat> for FileFormat
impl PartialEq<FileFormat> for FileFormat
source§fn eq(&self, other: &FileFormat) -> bool
fn eq(&self, other: &FileFormat) -> bool
source§impl PartialOrd<FileFormat> for FileFormat
impl PartialOrd<FileFormat> for FileFormat
source§fn partial_cmp(&self, other: &FileFormat) -> Option<Ordering>
fn partial_cmp(&self, other: &FileFormat) -> 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 FileFormat
impl StructuralEq for FileFormat
impl StructuralPartialEq for FileFormat
Auto Trait Implementations§
impl RefUnwindSafe for FileFormat
impl Send for FileFormat
impl Sync for FileFormat
impl Unpin for FileFormat
impl UnwindSafe for FileFormat
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.