pub fn ser_aws_wafv2_custom_response_details(
object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::types::AwsWafv2CustomResponseDetails,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
if let Some(var_1) = &input.custom_response_body_key {
object.key("CustomResponseBodyKey").string(var_1.as_str());
}
if let Some(var_2) = &input.response_code {
object.key("ResponseCode").number(
#[allow(clippy::useless_conversion)]
::aws_smithy_types::Number::NegInt((*var_2).into()),
);
}
if let Some(var_3) = &input.response_headers {
let mut array_4 = object.key("ResponseHeaders").start_array();
for item_5 in var_3 {
{
#[allow(unused_mut)]
let mut object_6 = array_4.value().start_object();
crate::protocol_serde::shape_aws_wafv2_custom_http_header::ser_aws_wafv2_custom_http_header(&mut object_6, item_5)?;
object_6.finish();
}
}
array_4.finish();
}
Ok(())
}
pub(crate) fn de_aws_wafv2_custom_response_details<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
_value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::AwsWafv2CustomResponseDetails>, ::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::AwsWafv2CustomResponseDetailsBuilder::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() {
"CustomResponseBodyKey" => {
builder = builder.set_custom_response_body_key(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"ResponseCode" => {
builder = builder.set_response_code(
::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
.map(i32::try_from)
.transpose()?,
);
}
"ResponseHeaders" => {
builder = builder.set_response_headers(
crate::protocol_serde::shape_aws_wafv2_insert_headers_list::de_aws_wafv2_insert_headers_list(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(builder.build()))
}
_ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
"expected start object or null",
)),
}
}