Skip to main content

aws_sdk_quicksight/protocol_serde/
shape_ip_restriction_rule_map.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_ip_restriction_rule_map<'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, ::std::string::String>>,
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 = ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
22                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
23                            .transpose()?;
24                        match value {
25                            Some(value) => {
26                                map.insert(key, value);
27                            }
28                            None => {
29                                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
30                                    "dense map cannot contain null values",
31                                ))
32                            }
33                        }
34                    }
35                    other => {
36                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
37                            "expected object key or end object, found: {other:?}"
38                        )))
39                    }
40                }
41            }
42            Ok(Some(map))
43        }
44        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
45            "expected start object or null",
46        )),
47    }
48}