// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_config_rule(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::ConfigRule,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    if let Some(var_1) = &input.config_rule_name {
        object.key("ConfigRuleName").string(var_1.as_str());
    }
    if let Some(var_2) = &input.config_rule_arn {
        object.key("ConfigRuleArn").string(var_2.as_str());
    }
    if let Some(var_3) = &input.config_rule_id {
        object.key("ConfigRuleId").string(var_3.as_str());
    }
    if let Some(var_4) = &input.description {
        object.key("Description").string(var_4.as_str());
    }
    if let Some(var_5) = &input.scope {
        #[allow(unused_mut)]
        let mut object_6 = object.key("Scope").start_object();
        crate::protocol_serde::shape_scope::ser_scope(&mut object_6, var_5)?;
        object_6.finish();
    }
    if let Some(var_7) = &input.source {
        #[allow(unused_mut)]
        let mut object_8 = object.key("Source").start_object();
        crate::protocol_serde::shape_source::ser_source(&mut object_8, var_7)?;
        object_8.finish();
    }
    if let Some(var_9) = &input.input_parameters {
        object.key("InputParameters").string(var_9.as_str());
    }
    if let Some(var_10) = &input.maximum_execution_frequency {
        object.key("MaximumExecutionFrequency").string(var_10.as_str());
    }
    if let Some(var_11) = &input.config_rule_state {
        object.key("ConfigRuleState").string(var_11.as_str());
    }
    if let Some(var_12) = &input.created_by {
        object.key("CreatedBy").string(var_12.as_str());
    }
    if let Some(var_13) = &input.evaluation_modes {
        let mut array_14 = object.key("EvaluationModes").start_array();
        for item_15 in var_13 {
            {
                #[allow(unused_mut)]
                let mut object_16 = array_14.value().start_object();
                crate::protocol_serde::shape_evaluation_mode_configuration::ser_evaluation_mode_configuration(&mut object_16, item_15)?;
                object_16.finish();
            }
        }
        array_14.finish();
    }
    Ok(())
}

pub(crate) fn de_config_rule<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::ConfigRule>, ::aws_smithy_json::deserialize::error::DeserializeError>
where
    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
{
    match tokens.next().transpose()? {
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
            #[allow(unused_mut)]
            let mut builder = crate::types::builders::ConfigRuleBuilder::default();
            loop {
                match tokens.next().transpose()? {
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
                        "ConfigRuleName" => {
                            builder = builder.set_config_rule_name(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "ConfigRuleArn" => {
                            builder = builder.set_config_rule_arn(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "ConfigRuleId" => {
                            builder = builder.set_config_rule_id(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "Description" => {
                            builder = builder.set_description(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "Scope" => {
                            builder = builder.set_scope(crate::protocol_serde::shape_scope::de_scope(tokens, _value)?);
                        }
                        "Source" => {
                            builder = builder.set_source(crate::protocol_serde::shape_source::de_source(tokens, _value)?);
                        }
                        "InputParameters" => {
                            builder = builder.set_input_parameters(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "MaximumExecutionFrequency" => {
                            builder = builder.set_maximum_execution_frequency(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::MaximumExecutionFrequency::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        "ConfigRuleState" => {
                            builder = builder.set_config_rule_state(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::ConfigRuleState::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        "CreatedBy" => {
                            builder = builder.set_created_by(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "EvaluationModes" => {
                            builder =
                                builder.set_evaluation_modes(crate::protocol_serde::shape_evaluation_modes::de_evaluation_modes(tokens, _value)?);
                        }
                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
                    },
                    other => {
                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
                            "expected object key or end object, found: {other:?}"
                        )))
                    }
                }
            }
            Ok(Some(crate::serde_util::config_rule_correct_errors(builder).build()))
        }
        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "expected start object or null",
        )),
    }
}
