pub fn ser_image_custom_action(
object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::types::ImageCustomAction,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
{
object.key("CustomActionId").string(input.custom_action_id.as_str());
}
{
object.key("Name").string(input.name.as_str());
}
if let Some(var_1) = &input.status {
object.key("Status").string(var_1.as_str());
}
{
object.key("Trigger").string(input.trigger.as_str());
}
{
let mut array_2 = object.key("ActionOperations").start_array();
for item_3 in &input.action_operations {
{
#[allow(unused_mut)]
let mut object_4 = array_2.value().start_object();
crate::protocol_serde::shape_image_custom_action_operation::ser_image_custom_action_operation(&mut object_4, item_3)?;
object_4.finish();
}
}
array_2.finish();
}
Ok(())
}
pub(crate) fn de_image_custom_action<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
_value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::ImageCustomAction>, ::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::ImageCustomActionBuilder::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() {
"CustomActionId" => {
builder = builder.set_custom_action_id(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"Name" => {
builder = builder.set_name(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"Status" => {
builder = builder.set_status(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| crate::types::WidgetStatus::from(u.as_ref())))
.transpose()?,
);
}
"Trigger" => {
builder = builder.set_trigger(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| crate::types::ImageCustomActionTrigger::from(u.as_ref())))
.transpose()?,
);
}
"ActionOperations" => {
builder = builder.set_action_operations(
crate::protocol_serde::shape_image_custom_action_operation_list::de_image_custom_action_operation_list(
tokens, _value,
)?,
);
}
_ => ::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::image_custom_action_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",
)),
}
}