pub fn ser_kms_grant_configuration(
object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::types::KmsGrantConfiguration,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
{
let mut array_1 = object.key("operations").start_array();
for item_2 in &input.operations {
{
array_1.value().string(item_2.as_str());
}
}
array_1.finish();
}
{
object.key("granteePrincipal").string(input.grantee_principal.as_str());
}
if let Some(var_3) = &input.retiring_principal {
object.key("retiringPrincipal").string(var_3.as_str());
}
if let Some(var_4) = &input.constraints {
#[allow(unused_mut)]
let mut object_5 = object.key("constraints").start_object();
crate::protocol_serde::shape_kms_grant_constraints::ser_kms_grant_constraints(&mut object_5, var_4)?;
object_5.finish();
}
{
object.key("issuingAccount").string(input.issuing_account.as_str());
}
Ok(())
}
pub(crate) fn de_kms_grant_configuration<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
_value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::KmsGrantConfiguration>, ::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::KmsGrantConfigurationBuilder::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() {
"operations" => {
builder = builder.set_operations(crate::protocol_serde::shape_kms_grant_operations_list::de_kms_grant_operations_list(
tokens, _value,
)?);
}
"granteePrincipal" => {
builder = builder.set_grantee_principal(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"retiringPrincipal" => {
builder = builder.set_retiring_principal(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"constraints" => {
builder = builder.set_constraints(crate::protocol_serde::shape_kms_grant_constraints::de_kms_grant_constraints(
tokens, _value,
)?);
}
"issuingAccount" => {
builder = builder.set_issuing_account(
::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::kms_grant_configuration_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",
)),
}
}