aws-sdk-wafv2 1.130.0

AWS SDK for AWS WAFV2
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_aws_managed_rules_atp_rule_set(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::AwsManagedRulesAtpRuleSet,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    {
        object.key("LoginPath").string(input.login_path.as_str());
    }
    if let Some(var_1) = &input.request_inspection {
        #[allow(unused_mut)]
        let mut object_2 = object.key("RequestInspection").start_object();
        crate::protocol_serde::shape_request_inspection::ser_request_inspection(&mut object_2, var_1)?;
        object_2.finish();
    }
    if let Some(var_3) = &input.response_inspection {
        #[allow(unused_mut)]
        let mut object_4 = object.key("ResponseInspection").start_object();
        crate::protocol_serde::shape_response_inspection::ser_response_inspection(&mut object_4, var_3)?;
        object_4.finish();
    }
    if input.enable_regex_in_path {
        object.key("EnableRegexInPath").boolean(input.enable_regex_in_path);
    }
    Ok(())
}

pub(crate) fn de_aws_managed_rules_atp_rule_set<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
    depth: u32,
) -> ::std::result::Result<Option<crate::types::AwsManagedRulesAtpRuleSet>, ::aws_smithy_json::deserialize::error::DeserializeError>
where
    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
{
    if depth >= 128u32 {
        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "maximum nesting depth exceeded",
        ));
    }
    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::AwsManagedRulesAtpRuleSetBuilder::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() {
                        "LoginPath" => {
                            builder = builder.set_login_path(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "RequestInspection" => {
                            builder = builder.set_request_inspection(crate::protocol_serde::shape_request_inspection::de_request_inspection(
                                tokens,
                                _value,
                                depth + 1,
                            )?);
                        }
                        "ResponseInspection" => {
                            builder = builder.set_response_inspection(crate::protocol_serde::shape_response_inspection::de_response_inspection(
                                tokens,
                                _value,
                                depth + 1,
                            )?);
                        }
                        "EnableRegexInPath" => {
                            builder = builder.set_enable_regex_in_path(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
                        }
                        _ => ::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::aws_managed_rules_atp_rule_set_correct_errors(builder)
                    .build()
                    .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
            ))
        }
        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "expected start object or null",
        )),
    }
}