aws_sdk_appmesh/protocol_serde/
shape_http_gateway_route_header.rs1pub fn ser_http_gateway_route_header(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::HttpGatewayRouteHeader,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 {
7 object.key("name").string(input.name.as_str());
8 }
9 if let Some(var_1) = &input.invert {
10 object.key("invert").boolean(*var_1);
11 }
12 if let Some(var_2) = &input.r#match {
13 #[allow(unused_mut)]
14 let mut object_3 = object.key("match").start_object();
15 crate::protocol_serde::shape_header_match_method::ser_header_match_method(&mut object_3, var_2)?;
16 object_3.finish();
17 }
18 Ok(())
19}
20
21pub(crate) fn de_http_gateway_route_header<'a, I>(
22 tokens: &mut ::std::iter::Peekable<I>,
23) -> ::std::result::Result<Option<crate::types::HttpGatewayRouteHeader>, ::aws_smithy_json::deserialize::error::DeserializeError>
24where
25 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
26{
27 match tokens.next().transpose()? {
28 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
29 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
30 #[allow(unused_mut)]
31 let mut builder = crate::types::builders::HttpGatewayRouteHeaderBuilder::default();
32 loop {
33 match tokens.next().transpose()? {
34 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
35 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
36 "name" => {
37 builder = builder.set_name(
38 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
39 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
40 .transpose()?,
41 );
42 }
43 "invert" => {
44 builder = builder.set_invert(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
45 }
46 "match" => {
47 builder = builder.set_match(crate::protocol_serde::shape_header_match_method::de_header_match_method(tokens)?);
48 }
49 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
50 },
51 other => {
52 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
53 "expected object key or end object, found: {:?}",
54 other
55 )))
56 }
57 }
58 }
59 Ok(Some(
60 crate::serde_util::http_gateway_route_header_correct_errors(builder)
61 .build()
62 .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
63 ))
64 }
65 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
66 "expected start object or null",
67 )),
68 }
69}