aws_sdk_databrew/protocol_serde/
shape_validation_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_validation_configuration(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::ValidationConfiguration,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    {
7        object.key("RulesetArn").string(input.ruleset_arn.as_str());
8    }
9    if let Some(var_1) = &input.validation_mode {
10        object.key("ValidationMode").string(var_1.as_str());
11    }
12    Ok(())
13}
14
15pub(crate) fn de_validation_configuration<'a, I>(
16    tokens: &mut ::std::iter::Peekable<I>,
17) -> ::std::result::Result<Option<crate::types::ValidationConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
18where
19    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
20{
21    match tokens.next().transpose()? {
22        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
23        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
24            #[allow(unused_mut)]
25            let mut builder = crate::types::builders::ValidationConfigurationBuilder::default();
26            loop {
27                match tokens.next().transpose()? {
28                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
29                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
30                        "RulesetArn" => {
31                            builder = builder.set_ruleset_arn(
32                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
33                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
34                                    .transpose()?,
35                            );
36                        }
37                        "ValidationMode" => {
38                            builder = builder.set_validation_mode(
39                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
40                                    .map(|s| s.to_unescaped().map(|u| crate::types::ValidationMode::from(u.as_ref())))
41                                    .transpose()?,
42                            );
43                        }
44                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
45                    },
46                    other => {
47                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
48                            "expected object key or end object, found: {:?}",
49                            other
50                        )))
51                    }
52                }
53            }
54            Ok(Some(
55                crate::serde_util::validation_configuration_correct_errors(builder)
56                    .build()
57                    .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
58            ))
59        }
60        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
61            "expected start object or null",
62        )),
63    }
64}