aws_sdk_databrew/protocol_serde/
shape_entity_detector_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_entity_detector_configuration(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::EntityDetectorConfiguration,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    {
7        let mut array_1 = object.key("EntityTypes").start_array();
8        for item_2 in &input.entity_types {
9            {
10                array_1.value().string(item_2.as_str());
11            }
12        }
13        array_1.finish();
14    }
15    if let Some(var_3) = &input.allowed_statistics {
16        let mut array_4 = object.key("AllowedStatistics").start_array();
17        for item_5 in var_3 {
18            {
19                #[allow(unused_mut)]
20                let mut object_6 = array_4.value().start_object();
21                crate::protocol_serde::shape_allowed_statistics::ser_allowed_statistics(&mut object_6, item_5)?;
22                object_6.finish();
23            }
24        }
25        array_4.finish();
26    }
27    Ok(())
28}
29
30pub(crate) fn de_entity_detector_configuration<'a, I>(
31    tokens: &mut ::std::iter::Peekable<I>,
32) -> ::std::result::Result<Option<crate::types::EntityDetectorConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
33where
34    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
35{
36    match tokens.next().transpose()? {
37        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
38        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
39            #[allow(unused_mut)]
40            let mut builder = crate::types::builders::EntityDetectorConfigurationBuilder::default();
41            loop {
42                match tokens.next().transpose()? {
43                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
44                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
45                        "EntityTypes" => {
46                            builder = builder.set_entity_types(crate::protocol_serde::shape_entity_type_list::de_entity_type_list(tokens)?);
47                        }
48                        "AllowedStatistics" => {
49                            builder = builder
50                                .set_allowed_statistics(crate::protocol_serde::shape_allowed_statistic_list::de_allowed_statistic_list(tokens)?);
51                        }
52                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
53                    },
54                    other => {
55                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
56                            "expected object key or end object, found: {other:?}"
57                        )))
58                    }
59                }
60            }
61            Ok(Some(
62                crate::serde_util::entity_detector_configuration_correct_errors(builder)
63                    .build()
64                    .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
65            ))
66        }
67        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
68            "expected start object or null",
69        )),
70    }
71}