Skip to main content

aws_sdk_securityhub/protocol_serde/
shape_parameter_definitions.rs

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