aws_sdk_databasemigration/protocol_serde/
shape_kafka_settings.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_kafka_settings(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::KafkaSettings,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.broker {
7        object.key("Broker").string(var_1.as_str());
8    }
9    if let Some(var_2) = &input.topic {
10        object.key("Topic").string(var_2.as_str());
11    }
12    if let Some(var_3) = &input.message_format {
13        object.key("MessageFormat").string(var_3.as_str());
14    }
15    if let Some(var_4) = &input.include_transaction_details {
16        object.key("IncludeTransactionDetails").boolean(*var_4);
17    }
18    if let Some(var_5) = &input.include_partition_value {
19        object.key("IncludePartitionValue").boolean(*var_5);
20    }
21    if let Some(var_6) = &input.partition_include_schema_table {
22        object.key("PartitionIncludeSchemaTable").boolean(*var_6);
23    }
24    if let Some(var_7) = &input.include_table_alter_operations {
25        object.key("IncludeTableAlterOperations").boolean(*var_7);
26    }
27    if let Some(var_8) = &input.include_control_details {
28        object.key("IncludeControlDetails").boolean(*var_8);
29    }
30    if let Some(var_9) = &input.message_max_bytes {
31        object.key("MessageMaxBytes").number(
32            #[allow(clippy::useless_conversion)]
33            ::aws_smithy_types::Number::NegInt((*var_9).into()),
34        );
35    }
36    if let Some(var_10) = &input.include_null_and_empty {
37        object.key("IncludeNullAndEmpty").boolean(*var_10);
38    }
39    if let Some(var_11) = &input.security_protocol {
40        object.key("SecurityProtocol").string(var_11.as_str());
41    }
42    if let Some(var_12) = &input.ssl_client_certificate_arn {
43        object.key("SslClientCertificateArn").string(var_12.as_str());
44    }
45    if let Some(var_13) = &input.ssl_client_key_arn {
46        object.key("SslClientKeyArn").string(var_13.as_str());
47    }
48    if let Some(var_14) = &input.ssl_client_key_password {
49        object.key("SslClientKeyPassword").string(var_14.as_str());
50    }
51    if let Some(var_15) = &input.ssl_ca_certificate_arn {
52        object.key("SslCaCertificateArn").string(var_15.as_str());
53    }
54    if let Some(var_16) = &input.sasl_username {
55        object.key("SaslUsername").string(var_16.as_str());
56    }
57    if let Some(var_17) = &input.sasl_password {
58        object.key("SaslPassword").string(var_17.as_str());
59    }
60    if let Some(var_18) = &input.no_hex_prefix {
61        object.key("NoHexPrefix").boolean(*var_18);
62    }
63    if let Some(var_19) = &input.sasl_mechanism {
64        object.key("SaslMechanism").string(var_19.as_str());
65    }
66    if let Some(var_20) = &input.ssl_endpoint_identification_algorithm {
67        object.key("SslEndpointIdentificationAlgorithm").string(var_20.as_str());
68    }
69    if let Some(var_21) = &input.use_large_integer_value {
70        object.key("UseLargeIntegerValue").boolean(*var_21);
71    }
72    Ok(())
73}
74
75pub(crate) fn de_kafka_settings<'a, I>(
76    tokens: &mut ::std::iter::Peekable<I>,
77) -> ::std::result::Result<Option<crate::types::KafkaSettings>, ::aws_smithy_json::deserialize::error::DeserializeError>
78where
79    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
80{
81    match tokens.next().transpose()? {
82        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
83        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
84            #[allow(unused_mut)]
85            let mut builder = crate::types::builders::KafkaSettingsBuilder::default();
86            loop {
87                match tokens.next().transpose()? {
88                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
89                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
90                        "Broker" => {
91                            builder = builder.set_broker(
92                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
93                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
94                                    .transpose()?,
95                            );
96                        }
97                        "Topic" => {
98                            builder = builder.set_topic(
99                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
100                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
101                                    .transpose()?,
102                            );
103                        }
104                        "MessageFormat" => {
105                            builder = builder.set_message_format(
106                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
107                                    .map(|s| s.to_unescaped().map(|u| crate::types::MessageFormatValue::from(u.as_ref())))
108                                    .transpose()?,
109                            );
110                        }
111                        "IncludeTransactionDetails" => {
112                            builder =
113                                builder.set_include_transaction_details(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
114                        }
115                        "IncludePartitionValue" => {
116                            builder = builder.set_include_partition_value(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
117                        }
118                        "PartitionIncludeSchemaTable" => {
119                            builder = builder
120                                .set_partition_include_schema_table(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
121                        }
122                        "IncludeTableAlterOperations" => {
123                            builder = builder
124                                .set_include_table_alter_operations(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
125                        }
126                        "IncludeControlDetails" => {
127                            builder = builder.set_include_control_details(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
128                        }
129                        "MessageMaxBytes" => {
130                            builder = builder.set_message_max_bytes(
131                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
132                                    .map(i32::try_from)
133                                    .transpose()?,
134                            );
135                        }
136                        "IncludeNullAndEmpty" => {
137                            builder = builder.set_include_null_and_empty(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
138                        }
139                        "SecurityProtocol" => {
140                            builder = builder.set_security_protocol(
141                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
142                                    .map(|s| s.to_unescaped().map(|u| crate::types::KafkaSecurityProtocol::from(u.as_ref())))
143                                    .transpose()?,
144                            );
145                        }
146                        "SslClientCertificateArn" => {
147                            builder = builder.set_ssl_client_certificate_arn(
148                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
149                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
150                                    .transpose()?,
151                            );
152                        }
153                        "SslClientKeyArn" => {
154                            builder = builder.set_ssl_client_key_arn(
155                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
156                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
157                                    .transpose()?,
158                            );
159                        }
160                        "SslClientKeyPassword" => {
161                            builder = builder.set_ssl_client_key_password(
162                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
163                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
164                                    .transpose()?,
165                            );
166                        }
167                        "SslCaCertificateArn" => {
168                            builder = builder.set_ssl_ca_certificate_arn(
169                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
170                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
171                                    .transpose()?,
172                            );
173                        }
174                        "SaslUsername" => {
175                            builder = builder.set_sasl_username(
176                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
177                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
178                                    .transpose()?,
179                            );
180                        }
181                        "SaslPassword" => {
182                            builder = builder.set_sasl_password(
183                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
184                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
185                                    .transpose()?,
186                            );
187                        }
188                        "NoHexPrefix" => {
189                            builder = builder.set_no_hex_prefix(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
190                        }
191                        "SaslMechanism" => {
192                            builder = builder.set_sasl_mechanism(
193                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
194                                    .map(|s| s.to_unescaped().map(|u| crate::types::KafkaSaslMechanism::from(u.as_ref())))
195                                    .transpose()?,
196                            );
197                        }
198                        "SslEndpointIdentificationAlgorithm" => {
199                            builder = builder.set_ssl_endpoint_identification_algorithm(
200                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
201                                    .map(|s| {
202                                        s.to_unescaped()
203                                            .map(|u| crate::types::KafkaSslEndpointIdentificationAlgorithm::from(u.as_ref()))
204                                    })
205                                    .transpose()?,
206                            );
207                        }
208                        "UseLargeIntegerValue" => {
209                            builder = builder.set_use_large_integer_value(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
210                        }
211                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
212                    },
213                    other => {
214                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
215                            "expected object key or end object, found: {:?}",
216                            other
217                        )))
218                    }
219                }
220            }
221            Ok(Some(builder.build()))
222        }
223        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
224            "expected start object or null",
225        )),
226    }
227}