aws_sdk_accessanalyzer/protocol_serde/
shape_finding_aggregation_account_details_map.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_finding_aggregation_account_details_map<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<::std::collections::HashMap<::std::string::String, i32>>, ::aws_smithy_json::deserialize::error::DeserializeError>
5where
6    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
7{
8    match tokens.next().transpose()? {
9        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
10        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
11            let mut map = ::std::collections::HashMap::new();
12            loop {
13                match tokens.next().transpose()? {
14                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
15                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
16                        let key = key.to_unescaped().map(|u| u.into_owned())?;
17                        let value = ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
18                            .map(i32::try_from)
19                            .transpose()?;
20                        if let Some(value) = value {
21                            map.insert(key, value);
22                        }
23                    }
24                    other => {
25                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
26                            "expected object key or end object, found: {:?}",
27                            other
28                        )))
29                    }
30                }
31            }
32            Ok(Some(map))
33        }
34        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
35            "expected start object or null",
36        )),
37    }
38}