aws_sdk_appmesh/protocol_serde/
shape_http_gateway_route_rewrite.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_http_gateway_route_rewrite(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::HttpGatewayRouteRewrite,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.prefix {
7        #[allow(unused_mut)]
8        let mut object_2 = object.key("prefix").start_object();
9        crate::protocol_serde::shape_http_gateway_route_prefix_rewrite::ser_http_gateway_route_prefix_rewrite(&mut object_2, var_1)?;
10        object_2.finish();
11    }
12    if let Some(var_3) = &input.path {
13        #[allow(unused_mut)]
14        let mut object_4 = object.key("path").start_object();
15        crate::protocol_serde::shape_http_gateway_route_path_rewrite::ser_http_gateway_route_path_rewrite(&mut object_4, var_3)?;
16        object_4.finish();
17    }
18    if let Some(var_5) = &input.hostname {
19        #[allow(unused_mut)]
20        let mut object_6 = object.key("hostname").start_object();
21        crate::protocol_serde::shape_gateway_route_hostname_rewrite::ser_gateway_route_hostname_rewrite(&mut object_6, var_5)?;
22        object_6.finish();
23    }
24    Ok(())
25}
26
27pub(crate) fn de_http_gateway_route_rewrite<'a, I>(
28    tokens: &mut ::std::iter::Peekable<I>,
29) -> ::std::result::Result<Option<crate::types::HttpGatewayRouteRewrite>, ::aws_smithy_json::deserialize::error::DeserializeError>
30where
31    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
32{
33    match tokens.next().transpose()? {
34        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
35        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
36            #[allow(unused_mut)]
37            let mut builder = crate::types::builders::HttpGatewayRouteRewriteBuilder::default();
38            loop {
39                match tokens.next().transpose()? {
40                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
41                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
42                        "prefix" => {
43                            builder = builder.set_prefix(
44                                crate::protocol_serde::shape_http_gateway_route_prefix_rewrite::de_http_gateway_route_prefix_rewrite(tokens)?,
45                            );
46                        }
47                        "path" => {
48                            builder = builder
49                                .set_path(crate::protocol_serde::shape_http_gateway_route_path_rewrite::de_http_gateway_route_path_rewrite(tokens)?);
50                        }
51                        "hostname" => {
52                            builder = builder.set_hostname(
53                                crate::protocol_serde::shape_gateway_route_hostname_rewrite::de_gateway_route_hostname_rewrite(tokens)?,
54                            );
55                        }
56                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
57                    },
58                    other => {
59                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
60                            "expected object key or end object, found: {other:?}"
61                        )))
62                    }
63                }
64            }
65            Ok(Some(builder.build()))
66        }
67        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
68            "expected start object or null",
69        )),
70    }
71}