aws_sdk_glue/protocol_serde/
shape_evaluated_metrics_map.rs1pub(crate) fn de_evaluated_metrics_map<'a, I>(
3 tokens: &mut ::std::iter::Peekable<I>,
4 _value: &'a [u8],
5) -> ::std::result::Result<Option<::std::collections::HashMap<::std::string::String, f64>>, ::aws_smithy_json::deserialize::error::DeserializeError>
6where
7 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
8{
9 match tokens.next().transpose()? {
10 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
11 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
12 let mut map = ::std::collections::HashMap::new();
13 loop {
14 match tokens.next().transpose()? {
15 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
16 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
17 let key = key.to_unescaped().map(|u| u.into_owned())?;
18 let value = ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?.map(|v| v.to_f64_lossy());
19 match value {
20 Some(value) => {
21 map.insert(key, value);
22 }
23 None => {
24 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
25 "dense map cannot contain null values",
26 ))
27 }
28 }
29 }
30 other => {
31 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
32 "expected object key or end object, found: {other:?}"
33 )))
34 }
35 }
36 }
37 Ok(Some(map))
38 }
39 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
40 "expected start object or null",
41 )),
42 }
43}