pub fn ser_address(
object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::types::Address,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
{
object.key("ContactName").string(input.contact_name.as_str());
}
{
object.key("ContactPhoneNumber").string(input.contact_phone_number.as_str());
}
{
object.key("AddressLine1").string(input.address_line1.as_str());
}
if let Some(var_1) = &input.address_line2 {
object.key("AddressLine2").string(var_1.as_str());
}
if let Some(var_2) = &input.address_line3 {
object.key("AddressLine3").string(var_2.as_str());
}
{
object.key("City").string(input.city.as_str());
}
{
object.key("StateOrRegion").string(input.state_or_region.as_str());
}
if let Some(var_3) = &input.district_or_county {
object.key("DistrictOrCounty").string(var_3.as_str());
}
{
object.key("PostalCode").string(input.postal_code.as_str());
}
{
object.key("CountryCode").string(input.country_code.as_str());
}
if let Some(var_4) = &input.municipality {
object.key("Municipality").string(var_4.as_str());
}
Ok(())
}
pub(crate) fn de_address<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
_value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::Address>, ::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::AddressBuilder::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() {
"ContactName" => {
builder = builder.set_contact_name(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"ContactPhoneNumber" => {
builder = builder.set_contact_phone_number(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"AddressLine1" => {
builder = builder.set_address_line1(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"AddressLine2" => {
builder = builder.set_address_line2(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"AddressLine3" => {
builder = builder.set_address_line3(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"City" => {
builder = builder.set_city(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"StateOrRegion" => {
builder = builder.set_state_or_region(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"DistrictOrCounty" => {
builder = builder.set_district_or_county(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"PostalCode" => {
builder = builder.set_postal_code(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"CountryCode" => {
builder = builder.set_country_code(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"Municipality" => {
builder = builder.set_municipality(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
_ => ::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::address_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",
)),
}
}