Enum aws_sdk_appmesh::model::HttpMethod
source · #[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
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§
source§impl HttpMethod
impl HttpMethod
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
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(())
}
Trait Implementations§
source§impl AsRef<str> for HttpMethod
impl AsRef<str> for HttpMethod
source§impl Clone for HttpMethod
impl Clone for HttpMethod
source§fn clone(&self) -> HttpMethod
fn clone(&self) -> HttpMethod
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for HttpMethod
impl Debug for HttpMethod
source§impl From<&str> for HttpMethod
impl From<&str> for HttpMethod
source§impl FromStr for HttpMethod
impl FromStr for HttpMethod
source§impl Hash for HttpMethod
impl Hash for HttpMethod
source§impl Ord for HttpMethod
impl Ord for HttpMethod
source§fn cmp(&self, other: &HttpMethod) -> Ordering
fn cmp(&self, other: &HttpMethod) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<HttpMethod> for HttpMethod
impl PartialEq<HttpMethod> for HttpMethod
source§fn eq(&self, other: &HttpMethod) -> bool
fn eq(&self, other: &HttpMethod) -> bool
source§impl PartialOrd<HttpMethod> for HttpMethod
impl PartialOrd<HttpMethod> for HttpMethod
source§fn partial_cmp(&self, other: &HttpMethod) -> Option<Ordering>
fn partial_cmp(&self, other: &HttpMethod) -> 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 HttpMethod
impl StructuralEq for HttpMethod
impl StructuralPartialEq for HttpMethod
Auto Trait Implementations§
impl RefUnwindSafe for HttpMethod
impl Send for HttpMethod
impl Sync for HttpMethod
impl Unpin for HttpMethod
impl UnwindSafe for HttpMethod
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.