Enum aws_sdk_ec2::model::TrafficType
source · #[non_exhaustive]
pub enum TrafficType {
Accept,
All,
Reject,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against TrafficType
, 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 traffictype = unimplemented!();
match traffictype {
TrafficType::Accept => { /* ... */ },
TrafficType::All => { /* ... */ },
TrafficType::Reject => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when traffictype
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant TrafficType::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
TrafficType::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 TrafficType::NewFeature
is defined.
Specifically, when traffictype
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on TrafficType::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
Accept
All
Reject
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl TrafficType
impl TrafficType
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
2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625
pub fn serialize_operation_crate_operation_create_flow_logs(
input: &crate::input::CreateFlowLogsInput,
) -> 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, "CreateFlowLogs", "2016-11-15");
#[allow(unused_mut)]
let mut scope_712 = writer.prefix("DryRun");
if let Some(var_713) = &input.dry_run {
scope_712.boolean(*var_713);
}
#[allow(unused_mut)]
let mut scope_714 = writer.prefix("ClientToken");
if let Some(var_715) = &input.client_token {
scope_714.string(var_715);
}
#[allow(unused_mut)]
let mut scope_716 = writer.prefix("DeliverLogsPermissionArn");
if let Some(var_717) = &input.deliver_logs_permission_arn {
scope_716.string(var_717);
}
#[allow(unused_mut)]
let mut scope_718 = writer.prefix("DeliverCrossAccountRole");
if let Some(var_719) = &input.deliver_cross_account_role {
scope_718.string(var_719);
}
#[allow(unused_mut)]
let mut scope_720 = writer.prefix("LogGroupName");
if let Some(var_721) = &input.log_group_name {
scope_720.string(var_721);
}
#[allow(unused_mut)]
let mut scope_722 = writer.prefix("ResourceId");
if let Some(var_723) = &input.resource_ids {
let mut list_725 = scope_722.start_list(true, Some("item"));
for item_724 in var_723 {
#[allow(unused_mut)]
let mut entry_726 = list_725.entry();
entry_726.string(item_724);
}
list_725.finish();
}
#[allow(unused_mut)]
let mut scope_727 = writer.prefix("ResourceType");
if let Some(var_728) = &input.resource_type {
scope_727.string(var_728.as_str());
}
#[allow(unused_mut)]
let mut scope_729 = writer.prefix("TrafficType");
if let Some(var_730) = &input.traffic_type {
scope_729.string(var_730.as_str());
}
#[allow(unused_mut)]
let mut scope_731 = writer.prefix("LogDestinationType");
if let Some(var_732) = &input.log_destination_type {
scope_731.string(var_732.as_str());
}
#[allow(unused_mut)]
let mut scope_733 = writer.prefix("LogDestination");
if let Some(var_734) = &input.log_destination {
scope_733.string(var_734);
}
#[allow(unused_mut)]
let mut scope_735 = writer.prefix("LogFormat");
if let Some(var_736) = &input.log_format {
scope_735.string(var_736);
}
#[allow(unused_mut)]
let mut scope_737 = writer.prefix("TagSpecification");
if let Some(var_738) = &input.tag_specifications {
let mut list_740 = scope_737.start_list(true, Some("item"));
for item_739 in var_738 {
#[allow(unused_mut)]
let mut entry_741 = list_740.entry();
crate::query_ser::serialize_structure_crate_model_tag_specification(
entry_741, item_739,
)?;
}
list_740.finish();
}
#[allow(unused_mut)]
let mut scope_742 = writer.prefix("MaxAggregationInterval");
if let Some(var_743) = &input.max_aggregation_interval {
scope_742.number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_743).into()),
);
}
#[allow(unused_mut)]
let mut scope_744 = writer.prefix("DestinationOptions");
if let Some(var_745) = &input.destination_options {
crate::query_ser::serialize_structure_crate_model_destination_options_request(
scope_744, var_745,
)?;
}
writer.finish();
Ok(aws_smithy_http::body::SdkBody::from(out))
}
Trait Implementations§
source§impl AsRef<str> for TrafficType
impl AsRef<str> for TrafficType
source§impl Clone for TrafficType
impl Clone for TrafficType
source§fn clone(&self) -> TrafficType
fn clone(&self) -> TrafficType
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TrafficType
impl Debug for TrafficType
source§impl From<&str> for TrafficType
impl From<&str> for TrafficType
source§impl FromStr for TrafficType
impl FromStr for TrafficType
source§impl Hash for TrafficType
impl Hash for TrafficType
source§impl Ord for TrafficType
impl Ord for TrafficType
source§fn cmp(&self, other: &TrafficType) -> Ordering
fn cmp(&self, other: &TrafficType) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<TrafficType> for TrafficType
impl PartialEq<TrafficType> for TrafficType
source§fn eq(&self, other: &TrafficType) -> bool
fn eq(&self, other: &TrafficType) -> bool
source§impl PartialOrd<TrafficType> for TrafficType
impl PartialOrd<TrafficType> for TrafficType
source§fn partial_cmp(&self, other: &TrafficType) -> Option<Ordering>
fn partial_cmp(&self, other: &TrafficType) -> 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 TrafficType
impl StructuralEq for TrafficType
impl StructuralPartialEq for TrafficType
Auto Trait Implementations§
impl RefUnwindSafe for TrafficType
impl Send for TrafficType
impl Sync for TrafficType
impl Unpin for TrafficType
impl UnwindSafe for TrafficType
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.