Enum aws_sdk_cloudformation::model::OnFailure
source · #[non_exhaustive]
pub enum OnFailure {
Delete,
DoNothing,
Rollback,
Unknown(UnknownVariantValue),
}Expand description
When writing a match expression against OnFailure, 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 onfailure = unimplemented!();
match onfailure {
OnFailure::Delete => { /* ... */ },
OnFailure::DoNothing => { /* ... */ },
OnFailure::Rollback => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when onfailure represents
NewFeature, the execution path will lead to the second last match arm,
even though the enum does not contain a variant OnFailure::NewFeature
in the current version of SDK. The reason is that the variable other,
created by the @ operator, is bound to
OnFailure::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 OnFailure::NewFeature is defined.
Specifically, when onfailure represents NewFeature,
the execution path will hit the second last match arm as before by virtue of
calling as_str on OnFailure::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
Delete
DoNothing
Rollback
Unknown(UnknownVariantValue)
Unknown contains new variants that have been added since this code was generated.
Implementations§
source§impl OnFailure
impl OnFailure
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
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411
pub fn serialize_operation_crate_operation_create_stack(
input: &crate::input::CreateStackInput,
) -> 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, "CreateStack", "2010-05-15");
#[allow(unused_mut)]
let mut scope_93 = writer.prefix("StackName");
if let Some(var_94) = &input.stack_name {
scope_93.string(var_94);
}
#[allow(unused_mut)]
let mut scope_95 = writer.prefix("TemplateBody");
if let Some(var_96) = &input.template_body {
scope_95.string(var_96);
}
#[allow(unused_mut)]
let mut scope_97 = writer.prefix("TemplateURL");
if let Some(var_98) = &input.template_url {
scope_97.string(var_98);
}
#[allow(unused_mut)]
let mut scope_99 = writer.prefix("Parameters");
if let Some(var_100) = &input.parameters {
let mut list_102 = scope_99.start_list(false, None);
for item_101 in var_100 {
#[allow(unused_mut)]
let mut entry_103 = list_102.entry();
crate::query_ser::serialize_structure_crate_model_parameter(entry_103, item_101)?;
}
list_102.finish();
}
#[allow(unused_mut)]
let mut scope_104 = writer.prefix("DisableRollback");
if let Some(var_105) = &input.disable_rollback {
scope_104.boolean(*var_105);
}
#[allow(unused_mut)]
let mut scope_106 = writer.prefix("RollbackConfiguration");
if let Some(var_107) = &input.rollback_configuration {
crate::query_ser::serialize_structure_crate_model_rollback_configuration(
scope_106, var_107,
)?;
}
#[allow(unused_mut)]
let mut scope_108 = writer.prefix("TimeoutInMinutes");
if let Some(var_109) = &input.timeout_in_minutes {
scope_108.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_109).into()),
);
}
#[allow(unused_mut)]
let mut scope_110 = writer.prefix("NotificationARNs");
if let Some(var_111) = &input.notification_ar_ns {
let mut list_113 = scope_110.start_list(false, None);
for item_112 in var_111 {
#[allow(unused_mut)]
let mut entry_114 = list_113.entry();
entry_114.string(item_112);
}
list_113.finish();
}
#[allow(unused_mut)]
let mut scope_115 = writer.prefix("Capabilities");
if let Some(var_116) = &input.capabilities {
let mut list_118 = scope_115.start_list(false, None);
for item_117 in var_116 {
#[allow(unused_mut)]
let mut entry_119 = list_118.entry();
entry_119.string(item_117.as_str());
}
list_118.finish();
}
#[allow(unused_mut)]
let mut scope_120 = writer.prefix("ResourceTypes");
if let Some(var_121) = &input.resource_types {
let mut list_123 = scope_120.start_list(false, None);
for item_122 in var_121 {
#[allow(unused_mut)]
let mut entry_124 = list_123.entry();
entry_124.string(item_122);
}
list_123.finish();
}
#[allow(unused_mut)]
let mut scope_125 = writer.prefix("RoleARN");
if let Some(var_126) = &input.role_arn {
scope_125.string(var_126);
}
#[allow(unused_mut)]
let mut scope_127 = writer.prefix("OnFailure");
if let Some(var_128) = &input.on_failure {
scope_127.string(var_128.as_str());
}
#[allow(unused_mut)]
let mut scope_129 = writer.prefix("StackPolicyBody");
if let Some(var_130) = &input.stack_policy_body {
scope_129.string(var_130);
}
#[allow(unused_mut)]
let mut scope_131 = writer.prefix("StackPolicyURL");
if let Some(var_132) = &input.stack_policy_url {
scope_131.string(var_132);
}
#[allow(unused_mut)]
let mut scope_133 = writer.prefix("Tags");
if let Some(var_134) = &input.tags {
let mut list_136 = scope_133.start_list(false, None);
for item_135 in var_134 {
#[allow(unused_mut)]
let mut entry_137 = list_136.entry();
crate::query_ser::serialize_structure_crate_model_tag(entry_137, item_135)?;
}
list_136.finish();
}
#[allow(unused_mut)]
let mut scope_138 = writer.prefix("ClientRequestToken");
if let Some(var_139) = &input.client_request_token {
scope_138.string(var_139);
}
#[allow(unused_mut)]
let mut scope_140 = writer.prefix("EnableTerminationProtection");
if let Some(var_141) = &input.enable_termination_protection {
scope_140.boolean(*var_141);
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}Trait Implementations§
source§impl Ord for OnFailure
impl Ord for OnFailure
source§impl PartialOrd<OnFailure> for OnFailure
impl PartialOrd<OnFailure> for OnFailure
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 OnFailure
impl StructuralEq for OnFailure
impl StructuralPartialEq for OnFailure
Auto Trait Implementations§
impl RefUnwindSafe for OnFailure
impl Send for OnFailure
impl Sync for OnFailure
impl Unpin for OnFailure
impl UnwindSafe for OnFailure
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.