aws_sdk_codeartifact/protocol_serde/
shape_package_group_origin_restrictions.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_package_group_origin_restrictions<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<
5    Option<::std::collections::HashMap<crate::types::PackageGroupOriginRestrictionType, crate::types::PackageGroupOriginRestriction>>,
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
20                            .to_unescaped()
21                            .map(|u| crate::types::PackageGroupOriginRestrictionType::from(u.as_ref()))?;
22                        let value = crate::protocol_serde::shape_package_group_origin_restriction::de_package_group_origin_restriction(tokens)?;
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}