pub fn ser_acl_grantee(
object_2: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::types::AclGrantee,
) -> Result<(), ::aws_smithy_types::error::operation::SerializationError> {
match input {
crate::types::AclGrantee::Id(inner) => {
object_2.key("id").string(inner.as_str());
}
crate::types::AclGrantee::Uri(inner) => {
object_2.key("uri").string(inner.as_str());
}
crate::types::AclGrantee::Unknown => return Err(::aws_smithy_types::error::operation::SerializationError::unknown_variant("AclGrantee")),
}
Ok(())
}
pub(crate) fn de_acl_grantee<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
) -> Result<Option<crate::types::AclGrantee>, ::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, .. }) => {
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() {
"id" => Some(crate::types::AclGrantee::Id(
::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 'id' cannot be null"))?,
)),
"uri" => Some(crate::types::AclGrantee::Uri(
::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 'uri' cannot be null"))?,
)),
_ => {
::aws_smithy_json::deserialize::token::skip_value(tokens)?;
Some(crate::types::AclGrantee::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)
}