pub fn ser_organization_access_grant_principal(
encoder: &mut ::aws_smithy_cbor::Encoder,
#[allow(unused)] input: &crate::types::OrganizationAccessGrantPrincipal,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
encoder.begin_map();
{
encoder.str("principalType").str(input.principal_type.as_str());
}
if let Some(var_1) = &input.principal_id {
encoder.str("principalId").str(var_1.as_str());
}
if let Some(var_2) = &input.principal_attributes {
encoder.str("principalAttributes");
encoder.array((*var_2).len());
for item_3 in var_2 {
{
crate::protocol_serde::shape_access_grant_principal_attribute::ser_access_grant_principal_attribute(encoder, item_3)?;
}
}
}
encoder.end();
Ok(())
}
pub(crate) fn de_organization_access_grant_principal(
decoder: &mut ::aws_smithy_cbor::Decoder,
depth: u32,
) -> ::std::result::Result<crate::types::OrganizationAccessGrantPrincipal, ::aws_smithy_cbor::decode::DeserializeError> {
if depth >= 128u32 {
return Err(::aws_smithy_cbor::decode::DeserializeError::custom(
"maximum nesting depth exceeded",
decoder.position(),
));
}
#[allow(clippy::match_single_binding, unused_variables)]
fn pair(
mut builder: crate::types::builders::OrganizationAccessGrantPrincipalBuilder,
decoder: &mut ::aws_smithy_cbor::Decoder,
depth: u32,
) -> ::std::result::Result<crate::types::builders::OrganizationAccessGrantPrincipalBuilder, ::aws_smithy_cbor::decode::DeserializeError> {
builder = match decoder.str()?.as_ref() {
"principalType" => builder.set_principal_type(Some(
decoder.string().map(|s| crate::types::OrganizationGrantPrincipalType::from(s.as_str()))?,
)),
"principalId" => {
::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| Ok(builder.set_principal_id(Some(decoder.string()?))))?
}
"principalAttributes" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
Ok(builder.set_principal_attributes(Some(
crate::protocol_serde::shape_access_grant_principal_attribute_list::de_access_grant_principal_attribute_list(decoder, depth + 1)?,
)))
})?,
_ => {
decoder.skip()?;
builder
}
};
Ok(builder)
}
let mut builder = crate::types::builders::OrganizationAccessGrantPrincipalBuilder::default();
match decoder.map()? {
None => loop {
match decoder.datatype()? {
::aws_smithy_cbor::data::Type::Break => {
decoder.skip()?;
break;
}
_ => {
builder = pair(builder, decoder, depth)?;
}
};
},
Some(n) => {
for _ in 0..n {
builder = pair(builder, decoder, depth)?;
}
}
};
#[allow(clippy::needless_question_mark)]
{
return Ok(crate::serde_util::organization_access_grant_principal_correct_errors(builder)
.build()
.map_err(|err| ::aws_smithy_cbor::decode::DeserializeError::custom(err.to_string(), decoder.position()))?);
}
}