pub fn ser_ec2_config(
object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::types::Ec2Config,
) -> Result<(), ::aws_smithy_types::error::operation::SerializationError> {
{
object.key("SubnetArn").string(input.subnet_arn.as_str());
}
{
let mut array_1 = object.key("SecurityGroupArns").start_array();
for item_2 in &input.security_group_arns {
{
array_1.value().string(item_2.as_str());
}
}
array_1.finish();
}
Ok(())
}
pub(crate) fn de_ec2_config<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
) -> Result<Option<crate::types::Ec2Config>, ::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::Ec2ConfigBuilder::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() {
"SubnetArn" => {
builder = builder.set_subnet_arn(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"SecurityGroupArns" => {
builder = builder.set_security_group_arns(
crate::protocol_serde::shape_ec2_security_group_arn_list::de_ec2_security_group_arn_list(tokens)?,
);
}
_ => ::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::ec2_config_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",
)),
}
}