#[non_exhaustive]
pub enum Origination {
    Allow,
    Deny,
    Unknown(UnknownVariantValue),
}
Expand description

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

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

Allow

§

Deny

§

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 89)
88
89
90
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/json_ser.rs (line 119)
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
pub fn serialize_structure_crate_input_create_origin_endpoint_input(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::input::CreateOriginEndpointInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_17) = &input.authorization {
        #[allow(unused_mut)]
        let mut object_18 = object.key("authorization").start_object();
        crate::json_ser::serialize_structure_crate_model_authorization(&mut object_18, var_17)?;
        object_18.finish();
    }
    if let Some(var_19) = &input.channel_id {
        object.key("channelId").string(var_19.as_str());
    }
    if let Some(var_20) = &input.cmaf_package {
        #[allow(unused_mut)]
        let mut object_21 = object.key("cmafPackage").start_object();
        crate::json_ser::serialize_structure_crate_model_cmaf_package_create_or_update_parameters(
            &mut object_21,
            var_20,
        )?;
        object_21.finish();
    }
    if let Some(var_22) = &input.dash_package {
        #[allow(unused_mut)]
        let mut object_23 = object.key("dashPackage").start_object();
        crate::json_ser::serialize_structure_crate_model_dash_package(&mut object_23, var_22)?;
        object_23.finish();
    }
    if let Some(var_24) = &input.description {
        object.key("description").string(var_24.as_str());
    }
    if let Some(var_25) = &input.hls_package {
        #[allow(unused_mut)]
        let mut object_26 = object.key("hlsPackage").start_object();
        crate::json_ser::serialize_structure_crate_model_hls_package(&mut object_26, var_25)?;
        object_26.finish();
    }
    if let Some(var_27) = &input.id {
        object.key("id").string(var_27.as_str());
    }
    if let Some(var_28) = &input.manifest_name {
        object.key("manifestName").string(var_28.as_str());
    }
    if let Some(var_29) = &input.mss_package {
        #[allow(unused_mut)]
        let mut object_30 = object.key("mssPackage").start_object();
        crate::json_ser::serialize_structure_crate_model_mss_package(&mut object_30, var_29)?;
        object_30.finish();
    }
    if let Some(var_31) = &input.origination {
        object.key("origination").string(var_31.as_str());
    }
    if input.startover_window_seconds != 0 {
        object.key("startoverWindowSeconds").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((input.startover_window_seconds).into()),
        );
    }
    if let Some(var_32) = &input.tags {
        #[allow(unused_mut)]
        let mut object_33 = object.key("tags").start_object();
        for (key_34, value_35) in var_32 {
            {
                object_33.key(key_34.as_str()).string(value_35.as_str());
            }
        }
        object_33.finish();
    }
    if input.time_delay_seconds != 0 {
        object.key("timeDelaySeconds").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((input.time_delay_seconds).into()),
        );
    }
    if let Some(var_36) = &input.whitelist {
        let mut array_37 = object.key("whitelist").start_array();
        for item_38 in var_36 {
            {
                array_37.value().string(item_38.as_str());
            }
        }
        array_37.finish();
    }
    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_39) = &input.tags {
        #[allow(unused_mut)]
        let mut object_40 = object.key("tags").start_object();
        for (key_41, value_42) in var_39 {
            {
                object_40.key(key_41.as_str()).string(value_42.as_str());
            }
        }
        object_40.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_input_update_channel_input(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::input::UpdateChannelInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_43) = &input.description {
        object.key("description").string(var_43.as_str());
    }
    Ok(())
}

pub fn serialize_structure_crate_input_update_origin_endpoint_input(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::input::UpdateOriginEndpointInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_44) = &input.authorization {
        #[allow(unused_mut)]
        let mut object_45 = object.key("authorization").start_object();
        crate::json_ser::serialize_structure_crate_model_authorization(&mut object_45, var_44)?;
        object_45.finish();
    }
    if let Some(var_46) = &input.cmaf_package {
        #[allow(unused_mut)]
        let mut object_47 = object.key("cmafPackage").start_object();
        crate::json_ser::serialize_structure_crate_model_cmaf_package_create_or_update_parameters(
            &mut object_47,
            var_46,
        )?;
        object_47.finish();
    }
    if let Some(var_48) = &input.dash_package {
        #[allow(unused_mut)]
        let mut object_49 = object.key("dashPackage").start_object();
        crate::json_ser::serialize_structure_crate_model_dash_package(&mut object_49, var_48)?;
        object_49.finish();
    }
    if let Some(var_50) = &input.description {
        object.key("description").string(var_50.as_str());
    }
    if let Some(var_51) = &input.hls_package {
        #[allow(unused_mut)]
        let mut object_52 = object.key("hlsPackage").start_object();
        crate::json_ser::serialize_structure_crate_model_hls_package(&mut object_52, var_51)?;
        object_52.finish();
    }
    if let Some(var_53) = &input.manifest_name {
        object.key("manifestName").string(var_53.as_str());
    }
    if let Some(var_54) = &input.mss_package {
        #[allow(unused_mut)]
        let mut object_55 = object.key("mssPackage").start_object();
        crate::json_ser::serialize_structure_crate_model_mss_package(&mut object_55, var_54)?;
        object_55.finish();
    }
    if let Some(var_56) = &input.origination {
        object.key("origination").string(var_56.as_str());
    }
    if input.startover_window_seconds != 0 {
        object.key("startoverWindowSeconds").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((input.startover_window_seconds).into()),
        );
    }
    if input.time_delay_seconds != 0 {
        object.key("timeDelaySeconds").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((input.time_delay_seconds).into()),
        );
    }
    if let Some(var_57) = &input.whitelist {
        let mut array_58 = object.key("whitelist").start_array();
        for item_59 in var_57 {
            {
                array_58.value().string(item_59.as_str());
            }
        }
        array_58.finish();
    }
    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