pub(crate) fn de_array_value<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
_value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::ArrayValue>, ::aws_smithy_json::deserialize::error::DeserializeError>
where
I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
{
let mut variant = None;
match tokens.next().transpose()? {
Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
match tokens.next().transpose()? {
Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
if let ::std::option::Option::Some(::std::result::Result::Ok(::aws_smithy_json::deserialize::Token::ValueNull { .. })) =
tokens.peek()
{
let _ = tokens.next().expect("peek returned a token")?;
continue;
}
let key = key.to_unescaped()?;
if key == "__type" {
::aws_smithy_json::deserialize::token::skip_value(tokens)?;
continue;
}
if variant.is_some() {
return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
"encountered mixed variants in union",
));
}
variant = match key.as_ref() {
"booleanValues" => Some(crate::types::ArrayValue::BooleanValues(
crate::protocol_serde::shape_boolean_array::de_boolean_array(tokens, _value)?.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'booleanValues' cannot be null")
})?,
)),
"longValues" => Some(crate::types::ArrayValue::LongValues(
crate::protocol_serde::shape_long_array::de_long_array(tokens, _value)?.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'longValues' cannot be null")
})?,
)),
"doubleValues" => Some(crate::types::ArrayValue::DoubleValues(
crate::protocol_serde::shape_double_array::de_double_array(tokens, _value)?.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'doubleValues' cannot be null")
})?,
)),
"stringValues" => Some(crate::types::ArrayValue::StringValues(
crate::protocol_serde::shape_string_array::de_string_array(tokens, _value)?.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'stringValues' cannot be null")
})?,
)),
"arrayValues" => Some(crate::types::ArrayValue::ArrayValues(
crate::protocol_serde::shape_array_of_array::de_array_of_array(tokens, _value)?.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'arrayValues' cannot be null")
})?,
)),
_ => {
::aws_smithy_json::deserialize::token::skip_value(tokens)?;
Some(crate::types::ArrayValue::Unknown)
}
};
}
other => {
return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
"expected object key or end object, found: {other:?}"
)))
}
}
},
_ => {
return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
"expected start object or null",
))
}
}
if variant.is_none() {
return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
"Union did not contain a valid variant.",
));
}
Ok(variant)
}
pub fn ser_array_value(
object_1: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::types::ArrayValue,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
match input {
crate::types::ArrayValue::BooleanValues(inner) => {
let mut array_1 = object_1.key("booleanValues").start_array();
for item_2 in inner {
{
array_1.value().boolean(*item_2);
}
}
array_1.finish();
}
crate::types::ArrayValue::LongValues(inner) => {
let mut array_3 = object_1.key("longValues").start_array();
for item_4 in inner {
{
array_3.value().number(
#[allow(clippy::useless_conversion)]
::aws_smithy_types::Number::NegInt((*item_4).into()),
);
}
}
array_3.finish();
}
crate::types::ArrayValue::DoubleValues(inner) => {
let mut array_5 = object_1.key("doubleValues").start_array();
for item_6 in inner {
{
array_5.value().number(
#[allow(clippy::useless_conversion)]
::aws_smithy_types::Number::Float((*item_6).into()),
);
}
}
array_5.finish();
}
crate::types::ArrayValue::StringValues(inner) => {
let mut array_7 = object_1.key("stringValues").start_array();
for item_8 in inner {
{
array_7.value().string(item_8.as_str());
}
}
array_7.finish();
}
crate::types::ArrayValue::ArrayValues(inner) => {
let mut array_9 = object_1.key("arrayValues").start_array();
for item_10 in inner {
{
#[allow(unused_mut)]
let mut object_11 = array_9.value().start_object();
crate::protocol_serde::shape_array_value::ser_array_value(&mut object_11, item_10)?;
object_11.finish();
}
}
array_9.finish();
}
crate::types::ArrayValue::Unknown => return Err(::aws_smithy_types::error::operation::SerializationError::unknown_variant("ArrayValue")),
}
Ok(())
}