pub(crate) fn de_dataset_detail_org_attributes<'a, I>(
tokens: &mut std::iter::Peekable<I>,
) -> Result<
Option<crate::types::DatasetDetailOrgAttributes>,
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 variant.is_some() {
return Err(
aws_smithy_json::deserialize::error::DeserializeError::custom(
"encountered mixed variants in union",
),
);
}
variant = match key.to_unescaped()?.as_ref() {
"vsam" => {
Some(crate::types::DatasetDetailOrgAttributes::Vsam(
crate::protocol_serde::shape_vsam_detail_attributes::de_vsam_detail_attributes(tokens)?
.ok_or_else(|| aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'vsam' cannot be null"))?
))
}
"gdg" => {
Some(crate::types::DatasetDetailOrgAttributes::Gdg(
crate::protocol_serde::shape_gdg_detail_attributes::de_gdg_detail_attributes(tokens)?
.ok_or_else(|| aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'gdg' cannot be null"))?
))
}
_ => {
aws_smithy_json::deserialize::token::skip_value(tokens)?;
Some(crate::types::DatasetDetailOrgAttributes::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",
),
)
}
}
Ok(variant)
}