pub(crate) fn de_access_grant(
decoder: &mut ::aws_smithy_cbor::Decoder,
depth: u32,
) -> ::std::result::Result<crate::types::AccessGrant, ::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::AccessGrantBuilder,
decoder: &mut ::aws_smithy_cbor::Decoder,
depth: u32,
) -> ::std::result::Result<crate::types::builders::AccessGrantBuilder, ::aws_smithy_cbor::decode::DeserializeError> {
builder = match decoder.str()?.as_ref() {
"grantId" => builder.set_grant_id(Some(decoder.string()?)),
"grantArn" => builder.set_grant_arn(Some(decoder.string()?)),
"name" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| Ok(builder.set_name(Some(decoder.string()?))))?,
"accountId" => builder.set_account_id(Some(decoder.string()?)),
"domainId" => builder.set_domain_id(Some(decoder.string()?)),
"principal" => builder.set_principal(Some(crate::protocol_serde::shape_access_grant_principal::de_access_grant_principal(
decoder,
depth + 1,
)?)),
"permission" => builder.set_permission(Some(decoder.string().map(|s| crate::types::AccessGrantPermission::from(s.as_str()))?)),
"grantType" => builder.set_grant_type(Some(decoder.string().map(|s| crate::types::AccessGrantType::from(s.as_str()))?)),
"createdBy" => builder.set_created_by(Some(decoder.string()?)),
"createdAt" => builder.set_created_at(Some(decoder.timestamp()?)),
"updatedAt" => builder.set_updated_at(Some(decoder.timestamp()?)),
"spaceId" => builder.set_space_id(Some(decoder.string()?)),
"scopedActions" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
Ok(
builder.set_scoped_actions(Some(crate::protocol_serde::shape_scoped_actions_list::de_scoped_actions_list(
decoder,
depth + 1,
)?)),
)
})?,
_ => {
decoder.skip()?;
builder
}
};
Ok(builder)
}
let mut builder = crate::types::builders::AccessGrantBuilder::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::access_grant_correct_errors(builder)
.build()
.map_err(|err| ::aws_smithy_cbor::decode::DeserializeError::custom(err.to_string(), decoder.position()))?);
}
}