#[non_exhaustive]
pub enum PermissionType {
    CustomerManaged,
    ServiceManaged,
    Unknown(UnknownVariantValue),
}
Expand description

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

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

CustomerManaged

Customer Managed

§

ServiceManaged

Service Managed

§

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 1786)
1785
1786
1787
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/json_ser.rs (line 25)
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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
pub fn serialize_structure_crate_input_create_workspace_input(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::input::CreateWorkspaceInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_1) = &input.account_access_type {
        object.key("accountAccessType").string(var_1.as_str());
    }
    if let Some(var_2) = &input.authentication_providers {
        let mut array_3 = object.key("authenticationProviders").start_array();
        for item_4 in var_2 {
            {
                array_3.value().string(item_4.as_str());
            }
        }
        array_3.finish();
    }
    if let Some(var_5) = &input.client_token {
        object.key("clientToken").string(var_5.as_str());
    }
    if let Some(var_6) = &input.organization_role_name {
        object.key("organizationRoleName").string(var_6.as_str());
    }
    if let Some(var_7) = &input.permission_type {
        object.key("permissionType").string(var_7.as_str());
    }
    if let Some(var_8) = &input.stack_set_name {
        object.key("stackSetName").string(var_8.as_str());
    }
    if let Some(var_9) = &input.tags {
        #[allow(unused_mut)]
        let mut object_10 = object.key("tags").start_object();
        for (key_11, value_12) in var_9 {
            {
                object_10.key(key_11.as_str()).string(value_12.as_str());
            }
        }
        object_10.finish();
    }
    if let Some(var_13) = &input.workspace_data_sources {
        let mut array_14 = object.key("workspaceDataSources").start_array();
        for item_15 in var_13 {
            {
                array_14.value().string(item_15.as_str());
            }
        }
        array_14.finish();
    }
    if let Some(var_16) = &input.workspace_description {
        object.key("workspaceDescription").string(var_16.as_str());
    }
    if let Some(var_17) = &input.workspace_name {
        object.key("workspaceName").string(var_17.as_str());
    }
    if let Some(var_18) = &input.workspace_notification_destinations {
        let mut array_19 = object
            .key("workspaceNotificationDestinations")
            .start_array();
        for item_20 in var_18 {
            {
                array_19.value().string(item_20.as_str());
            }
        }
        array_19.finish();
    }
    if let Some(var_21) = &input.workspace_organizational_units {
        let mut array_22 = object.key("workspaceOrganizationalUnits").start_array();
        for item_23 in var_21 {
            {
                array_22.value().string(item_23.as_str());
            }
        }
        array_22.finish();
    }
    if let Some(var_24) = &input.workspace_role_arn {
        object.key("workspaceRoleArn").string(var_24.as_str());
    }
    Ok(())
}

pub fn serialize_structure_crate_input_create_workspace_api_key_input(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::input::CreateWorkspaceApiKeyInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_25) = &input.key_name {
        object.key("keyName").string(var_25.as_str());
    }
    if let Some(var_26) = &input.key_role {
        object.key("keyRole").string(var_26.as_str());
    }
    if let Some(var_27) = &input.seconds_to_live {
        object.key("secondsToLive").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_27).into()),
        );
    }
    Ok(())
}

pub fn serialize_structure_crate_input_tag_resource_input(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::input::TagResourceInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_28) = &input.tags {
        #[allow(unused_mut)]
        let mut object_29 = object.key("tags").start_object();
        for (key_30, value_31) in var_28 {
            {
                object_29.key(key_30.as_str()).string(value_31.as_str());
            }
        }
        object_29.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_input_update_permissions_input(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::input::UpdatePermissionsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_32) = &input.update_instruction_batch {
        let mut array_33 = object.key("updateInstructionBatch").start_array();
        for item_34 in var_32 {
            {
                #[allow(unused_mut)]
                let mut object_35 = array_33.value().start_object();
                crate::json_ser::serialize_structure_crate_model_update_instruction(
                    &mut object_35,
                    item_34,
                )?;
                object_35.finish();
            }
        }
        array_33.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_input_update_workspace_input(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::input::UpdateWorkspaceInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_36) = &input.account_access_type {
        object.key("accountAccessType").string(var_36.as_str());
    }
    if let Some(var_37) = &input.organization_role_name {
        object.key("organizationRoleName").string(var_37.as_str());
    }
    if let Some(var_38) = &input.permission_type {
        object.key("permissionType").string(var_38.as_str());
    }
    if let Some(var_39) = &input.stack_set_name {
        object.key("stackSetName").string(var_39.as_str());
    }
    if let Some(var_40) = &input.workspace_data_sources {
        let mut array_41 = object.key("workspaceDataSources").start_array();
        for item_42 in var_40 {
            {
                array_41.value().string(item_42.as_str());
            }
        }
        array_41.finish();
    }
    if let Some(var_43) = &input.workspace_description {
        object.key("workspaceDescription").string(var_43.as_str());
    }
    if let Some(var_44) = &input.workspace_name {
        object.key("workspaceName").string(var_44.as_str());
    }
    if let Some(var_45) = &input.workspace_notification_destinations {
        let mut array_46 = object
            .key("workspaceNotificationDestinations")
            .start_array();
        for item_47 in var_45 {
            {
                array_46.value().string(item_47.as_str());
            }
        }
        array_46.finish();
    }
    if let Some(var_48) = &input.workspace_organizational_units {
        let mut array_49 = object.key("workspaceOrganizationalUnits").start_array();
        for item_50 in var_48 {
            {
                array_49.value().string(item_50.as_str());
            }
        }
        array_49.finish();
    }
    if let Some(var_51) = &input.workspace_role_arn {
        object.key("workspaceRoleArn").string(var_51.as_str());
    }
    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