#[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 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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Delete

§

DoNothing

§

Rollback

§

Unknown(UnknownVariantValue)

Unknown contains new variants that have been added since this code was generated.

Implementations§

Returns the &str value of the enum member.

Examples found in repository?
src/model.rs (line 14596)
14595
14596
14597
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/operation_ser.rs (line 376)
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))
}

Returns all the &str values of the enum members.

Trait Implementations§

Converts this type into a shared reference of the (usually inferred) input type.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more