#[non_exhaustive]
pub enum HttpMethod {
    Connect,
    Delete,
    Get,
    Head,
    Options,
    Patch,
    Post,
    Put,
    Trace,
    Unknown(UnknownVariantValue),
}
Expand description

When writing a match expression against HttpMethod, 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 httpmethod = unimplemented!();
match httpmethod {
    HttpMethod::Connect => { /* ... */ },
    HttpMethod::Delete => { /* ... */ },
    HttpMethod::Get => { /* ... */ },
    HttpMethod::Head => { /* ... */ },
    HttpMethod::Options => { /* ... */ },
    HttpMethod::Patch => { /* ... */ },
    HttpMethod::Post => { /* ... */ },
    HttpMethod::Put => { /* ... */ },
    HttpMethod::Trace => { /* ... */ },
    other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
    _ => { /* ... */ },
}

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

Connect

§

Delete

§

Get

§

Head

§

Options

§

Patch

§

Post

§

Put

§

Trace

§

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 5321)
5320
5321
5322
    fn as_ref(&self) -> &str {
        self.as_str()
    }
More examples
Hide additional examples
src/json_ser.rs (line 1096)
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
pub fn serialize_structure_crate_model_http_gateway_route_match(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::HttpGatewayRouteMatch,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_202) = &input.prefix {
        object.key("prefix").string(var_202.as_str());
    }
    if let Some(var_203) = &input.path {
        #[allow(unused_mut)]
        let mut object_204 = object.key("path").start_object();
        crate::json_ser::serialize_structure_crate_model_http_path_match(&mut object_204, var_203)?;
        object_204.finish();
    }
    if let Some(var_205) = &input.query_parameters {
        let mut array_206 = object.key("queryParameters").start_array();
        for item_207 in var_205 {
            {
                #[allow(unused_mut)]
                let mut object_208 = array_206.value().start_object();
                crate::json_ser::serialize_structure_crate_model_http_query_parameter(
                    &mut object_208,
                    item_207,
                )?;
                object_208.finish();
            }
        }
        array_206.finish();
    }
    if let Some(var_209) = &input.method {
        object.key("method").string(var_209.as_str());
    }
    if let Some(var_210) = &input.hostname {
        #[allow(unused_mut)]
        let mut object_211 = object.key("hostname").start_object();
        crate::json_ser::serialize_structure_crate_model_gateway_route_hostname_match(
            &mut object_211,
            var_210,
        )?;
        object_211.finish();
    }
    if let Some(var_212) = &input.headers {
        let mut array_213 = object.key("headers").start_array();
        for item_214 in var_212 {
            {
                #[allow(unused_mut)]
                let mut object_215 = array_213.value().start_object();
                crate::json_ser::serialize_structure_crate_model_http_gateway_route_header(
                    &mut object_215,
                    item_214,
                )?;
                object_215.finish();
            }
        }
        array_213.finish();
    }
    if let Some(var_216) = &input.port {
        object.key("port").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_216).into()),
        );
    }
    Ok(())
}

pub fn serialize_structure_crate_model_http_gateway_route_action(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::HttpGatewayRouteAction,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_217) = &input.target {
        #[allow(unused_mut)]
        let mut object_218 = object.key("target").start_object();
        crate::json_ser::serialize_structure_crate_model_gateway_route_target(
            &mut object_218,
            var_217,
        )?;
        object_218.finish();
    }
    if let Some(var_219) = &input.rewrite {
        #[allow(unused_mut)]
        let mut object_220 = object.key("rewrite").start_object();
        crate::json_ser::serialize_structure_crate_model_http_gateway_route_rewrite(
            &mut object_220,
            var_219,
        )?;
        object_220.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_model_grpc_gateway_route_match(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::GrpcGatewayRouteMatch,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_221) = &input.service_name {
        object.key("serviceName").string(var_221.as_str());
    }
    if let Some(var_222) = &input.hostname {
        #[allow(unused_mut)]
        let mut object_223 = object.key("hostname").start_object();
        crate::json_ser::serialize_structure_crate_model_gateway_route_hostname_match(
            &mut object_223,
            var_222,
        )?;
        object_223.finish();
    }
    if let Some(var_224) = &input.metadata {
        let mut array_225 = object.key("metadata").start_array();
        for item_226 in var_224 {
            {
                #[allow(unused_mut)]
                let mut object_227 = array_225.value().start_object();
                crate::json_ser::serialize_structure_crate_model_grpc_gateway_route_metadata(
                    &mut object_227,
                    item_226,
                )?;
                object_227.finish();
            }
        }
        array_225.finish();
    }
    if let Some(var_228) = &input.port {
        object.key("port").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_228).into()),
        );
    }
    Ok(())
}

pub fn serialize_structure_crate_model_grpc_gateway_route_action(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::GrpcGatewayRouteAction,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_229) = &input.target {
        #[allow(unused_mut)]
        let mut object_230 = object.key("target").start_object();
        crate::json_ser::serialize_structure_crate_model_gateway_route_target(
            &mut object_230,
            var_229,
        )?;
        object_230.finish();
    }
    if let Some(var_231) = &input.rewrite {
        #[allow(unused_mut)]
        let mut object_232 = object.key("rewrite").start_object();
        crate::json_ser::serialize_structure_crate_model_grpc_gateway_route_rewrite(
            &mut object_232,
            var_231,
        )?;
        object_232.finish();
    }
    Ok(())
}

pub fn serialize_structure_crate_model_http_route_match(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::model::HttpRouteMatch,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_233) = &input.prefix {
        object.key("prefix").string(var_233.as_str());
    }
    if let Some(var_234) = &input.path {
        #[allow(unused_mut)]
        let mut object_235 = object.key("path").start_object();
        crate::json_ser::serialize_structure_crate_model_http_path_match(&mut object_235, var_234)?;
        object_235.finish();
    }
    if let Some(var_236) = &input.query_parameters {
        let mut array_237 = object.key("queryParameters").start_array();
        for item_238 in var_236 {
            {
                #[allow(unused_mut)]
                let mut object_239 = array_237.value().start_object();
                crate::json_ser::serialize_structure_crate_model_http_query_parameter(
                    &mut object_239,
                    item_238,
                )?;
                object_239.finish();
            }
        }
        array_237.finish();
    }
    if let Some(var_240) = &input.method {
        object.key("method").string(var_240.as_str());
    }
    if let Some(var_241) = &input.scheme {
        object.key("scheme").string(var_241.as_str());
    }
    if let Some(var_242) = &input.headers {
        let mut array_243 = object.key("headers").start_array();
        for item_244 in var_242 {
            {
                #[allow(unused_mut)]
                let mut object_245 = array_243.value().start_object();
                crate::json_ser::serialize_structure_crate_model_http_route_header(
                    &mut object_245,
                    item_244,
                )?;
                object_245.finish();
            }
        }
        array_243.finish();
    }
    if let Some(var_246) = &input.port {
        object.key("port").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_246).into()),
        );
    }
    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