aws_sdk_databrew/protocol_serde/
shape_parameter_map.rs

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