#[non_exhaustive]
pub enum PermissionGroup {
    All,
    Unknown(UnknownVariantValue),
}
Expand description

When writing a match expression against PermissionGroup, 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 permissiongroup = unimplemented!();
match permissiongroup {
    PermissionGroup::All => { /* ... */ },
    other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
    _ => { /* ... */ },
}

The above code demonstrates that when permissiongroup represents NewFeature, the execution path will lead to the second last match arm, even though the enum does not contain a variant PermissionGroup::NewFeature in the current version of SDK. The reason is that the variable other, created by the @ operator, is bound to PermissionGroup::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 PermissionGroup::NewFeature is defined. Specifically, when permissiongroup represents NewFeature, the execution path will hit the second last match arm as before by virtue of calling as_str on PermissionGroup::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.
§

All

§

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 43008)
43007
43008
43009
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/query_ser.rs (line 5038)
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
pub fn serialize_structure_crate_model_load_permission_request(
    mut writer: aws_smithy_query::QueryValueWriter,
    input: &crate::model::LoadPermissionRequest,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    #[allow(unused_mut)]
    let mut scope_1409 = writer.prefix("Group");
    if let Some(var_1410) = &input.group {
        scope_1409.string(var_1410.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_1411 = writer.prefix("UserId");
    if let Some(var_1412) = &input.user_id {
        scope_1411.string(var_1412);
    }
    Ok(())
}

#[allow(unused_mut)]
pub fn serialize_structure_crate_model_launch_permission(
    mut writer: aws_smithy_query::QueryValueWriter,
    input: &crate::model::LaunchPermission,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    #[allow(unused_mut)]
    let mut scope_1413 = writer.prefix("Group");
    if let Some(var_1414) = &input.group {
        scope_1413.string(var_1414.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_1415 = writer.prefix("UserId");
    if let Some(var_1416) = &input.user_id {
        scope_1415.string(var_1416);
    }
    #[allow(unused_mut)]
    let mut scope_1417 = writer.prefix("OrganizationArn");
    if let Some(var_1418) = &input.organization_arn {
        scope_1417.string(var_1418);
    }
    #[allow(unused_mut)]
    let mut scope_1419 = writer.prefix("OrganizationalUnitArn");
    if let Some(var_1420) = &input.organizational_unit_arn {
        scope_1419.string(var_1420);
    }
    Ok(())
}

#[allow(unused_mut)]
pub fn serialize_structure_crate_model_ebs_instance_block_device_specification(
    mut writer: aws_smithy_query::QueryValueWriter,
    input: &crate::model::EbsInstanceBlockDeviceSpecification,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    #[allow(unused_mut)]
    let mut scope_1421 = writer.prefix("DeleteOnTermination");
    if let Some(var_1422) = &input.delete_on_termination {
        scope_1421.boolean(*var_1422);
    }
    #[allow(unused_mut)]
    let mut scope_1423 = writer.prefix("VolumeId");
    if let Some(var_1424) = &input.volume_id {
        scope_1423.string(var_1424);
    }
    Ok(())
}

#[allow(unused_mut)]
pub fn serialize_structure_crate_model_capacity_reservation_target(
    mut writer: aws_smithy_query::QueryValueWriter,
    input: &crate::model::CapacityReservationTarget,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    #[allow(unused_mut)]
    let mut scope_1425 = writer.prefix("CapacityReservationId");
    if let Some(var_1426) = &input.capacity_reservation_id {
        scope_1425.string(var_1426);
    }
    #[allow(unused_mut)]
    let mut scope_1427 = writer.prefix("CapacityReservationResourceGroupArn");
    if let Some(var_1428) = &input.capacity_reservation_resource_group_arn {
        scope_1427.string(var_1428);
    }
    Ok(())
}

#[allow(unused_mut)]
pub fn serialize_structure_crate_model_security_group_rule_request(
    mut writer: aws_smithy_query::QueryValueWriter,
    input: &crate::model::SecurityGroupRuleRequest,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    #[allow(unused_mut)]
    let mut scope_1429 = writer.prefix("IpProtocol");
    if let Some(var_1430) = &input.ip_protocol {
        scope_1429.string(var_1430);
    }
    #[allow(unused_mut)]
    let mut scope_1431 = writer.prefix("FromPort");
    if let Some(var_1432) = &input.from_port {
        scope_1431.number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_1432).into()),
        );
    }
    #[allow(unused_mut)]
    let mut scope_1433 = writer.prefix("ToPort");
    if let Some(var_1434) = &input.to_port {
        scope_1433.number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_1434).into()),
        );
    }
    #[allow(unused_mut)]
    let mut scope_1435 = writer.prefix("CidrIpv4");
    if let Some(var_1436) = &input.cidr_ipv4 {
        scope_1435.string(var_1436);
    }
    #[allow(unused_mut)]
    let mut scope_1437 = writer.prefix("CidrIpv6");
    if let Some(var_1438) = &input.cidr_ipv6 {
        scope_1437.string(var_1438);
    }
    #[allow(unused_mut)]
    let mut scope_1439 = writer.prefix("PrefixListId");
    if let Some(var_1440) = &input.prefix_list_id {
        scope_1439.string(var_1440);
    }
    #[allow(unused_mut)]
    let mut scope_1441 = writer.prefix("ReferencedGroupId");
    if let Some(var_1442) = &input.referenced_group_id {
        scope_1441.string(var_1442);
    }
    #[allow(unused_mut)]
    let mut scope_1443 = writer.prefix("Description");
    if let Some(var_1444) = &input.description {
        scope_1443.string(var_1444);
    }
    Ok(())
}

#[allow(unused_mut)]
pub fn serialize_structure_crate_model_create_volume_permission(
    mut writer: aws_smithy_query::QueryValueWriter,
    input: &crate::model::CreateVolumePermission,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    #[allow(unused_mut)]
    let mut scope_1445 = writer.prefix("Group");
    if let Some(var_1446) = &input.group {
        scope_1445.string(var_1446.as_str());
    }
    #[allow(unused_mut)]
    let mut scope_1447 = writer.prefix("UserId");
    if let Some(var_1448) = &input.user_id {
        scope_1447.string(var_1448);
    }
    Ok(())
}

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