pub(crate) fn de_keyspaces_cell_value<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
_value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::KeyspacesCellValue>, ::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() {
"asciiT" => Some(crate::types::KeyspacesCellValue::AsciiT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'asciiT' cannot be null")
})?,
)),
"bigintT" => Some(crate::types::KeyspacesCellValue::BigintT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'bigintT' cannot be null")
})?,
)),
"blobT" => Some(crate::types::KeyspacesCellValue::BlobT(
::aws_smithy_json::deserialize::token::expect_blob_or_null(tokens.next())?
.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'blobT' cannot be null"))?,
)),
"boolT" => Some(crate::types::KeyspacesCellValue::BoolT(
::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?
.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'boolT' cannot be null"))?,
)),
"counterT" => Some(crate::types::KeyspacesCellValue::CounterT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'counterT' cannot be null")
})?,
)),
"dateT" => Some(crate::types::KeyspacesCellValue::DateT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'dateT' cannot be null"))?,
)),
"decimalT" => Some(crate::types::KeyspacesCellValue::DecimalT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'decimalT' cannot be null")
})?,
)),
"doubleT" => Some(crate::types::KeyspacesCellValue::DoubleT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'doubleT' cannot be null")
})?,
)),
"durationT" => Some(crate::types::KeyspacesCellValue::DurationT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'durationT' cannot be null")
})?,
)),
"floatT" => Some(crate::types::KeyspacesCellValue::FloatT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'floatT' cannot be null")
})?,
)),
"inetT" => Some(crate::types::KeyspacesCellValue::InetT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'inetT' cannot be null"))?,
)),
"intT" => Some(crate::types::KeyspacesCellValue::IntT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'intT' cannot be null"))?,
)),
"listT" => Some(crate::types::KeyspacesCellValue::ListT(
crate::protocol_serde::shape_keyspaces_cell_list::de_keyspaces_cell_list(tokens, _value)?
.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'listT' cannot be null"))?,
)),
"mapT" => Some(crate::types::KeyspacesCellValue::MapT(
crate::protocol_serde::shape_keyspaces_cell_map::de_keyspaces_cell_map(tokens, _value)?
.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'mapT' cannot be null"))?,
)),
"setT" => Some(crate::types::KeyspacesCellValue::SetT(
crate::protocol_serde::shape_keyspaces_cell_list::de_keyspaces_cell_list(tokens, _value)?
.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'setT' cannot be null"))?,
)),
"smallintT" => Some(crate::types::KeyspacesCellValue::SmallintT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'smallintT' cannot be null")
})?,
)),
"textT" => Some(crate::types::KeyspacesCellValue::TextT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'textT' cannot be null"))?,
)),
"timeT" => Some(crate::types::KeyspacesCellValue::TimeT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'timeT' cannot be null"))?,
)),
"timestampT" => Some(crate::types::KeyspacesCellValue::TimestampT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'timestampT' cannot be null")
})?,
)),
"timeuuidT" => Some(crate::types::KeyspacesCellValue::TimeuuidT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'timeuuidT' cannot be null")
})?,
)),
"tinyintT" => Some(crate::types::KeyspacesCellValue::TinyintT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'tinyintT' cannot be null")
})?,
)),
"tupleT" => Some(crate::types::KeyspacesCellValue::TupleT(
crate::protocol_serde::shape_keyspaces_cell_list::de_keyspaces_cell_list(tokens, _value)?.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'tupleT' cannot be null")
})?,
)),
"uuidT" => Some(crate::types::KeyspacesCellValue::UuidT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'uuidT' cannot be null"))?,
)),
"varcharT" => Some(crate::types::KeyspacesCellValue::VarcharT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'varcharT' cannot be null")
})?,
)),
"varintT" => Some(crate::types::KeyspacesCellValue::VarintT(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?
.ok_or_else(|| {
::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'varintT' cannot be null")
})?,
)),
"udtT" => Some(crate::types::KeyspacesCellValue::UdtT(
crate::protocol_serde::shape_keyspaces_udt_map::de_keyspaces_udt_map(tokens, _value)?
.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'udtT' cannot be null"))?,
)),
_ => {
::aws_smithy_json::deserialize::token::skip_value(tokens)?;
Some(crate::types::KeyspacesCellValue::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)
}