pub fn ser_aws_iam_instance_profile(
object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::types::AwsIamInstanceProfile,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
if let Some(var_1) = &input.arn {
object.key("Arn").string(var_1.as_str());
}
if let Some(var_2) = &input.create_date {
object.key("CreateDate").string(var_2.as_str());
}
if let Some(var_3) = &input.instance_profile_id {
object.key("InstanceProfileId").string(var_3.as_str());
}
if let Some(var_4) = &input.instance_profile_name {
object.key("InstanceProfileName").string(var_4.as_str());
}
if let Some(var_5) = &input.path {
object.key("Path").string(var_5.as_str());
}
if let Some(var_6) = &input.roles {
let mut array_7 = object.key("Roles").start_array();
for item_8 in var_6 {
{
#[allow(unused_mut)]
let mut object_9 = array_7.value().start_object();
crate::protocol_serde::shape_aws_iam_instance_profile_role::ser_aws_iam_instance_profile_role(&mut object_9, item_8)?;
object_9.finish();
}
}
array_7.finish();
}
Ok(())
}
pub(crate) fn de_aws_iam_instance_profile<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
_value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::AwsIamInstanceProfile>, ::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::AwsIamInstanceProfileBuilder::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() {
"Arn" => {
builder = builder.set_arn(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"CreateDate" => {
builder = builder.set_create_date(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"InstanceProfileId" => {
builder = builder.set_instance_profile_id(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"InstanceProfileName" => {
builder = builder.set_instance_profile_name(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"Path" => {
builder = builder.set_path(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"Roles" => {
builder = builder.set_roles(
crate::protocol_serde::shape_aws_iam_instance_profile_roles::de_aws_iam_instance_profile_roles(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(builder.build()))
}
_ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
"expected start object or null",
)),
}
}