Skip to main content

aws_sdk_lambda/protocol_serde/
shape_string_list.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_string_list<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4    _value: &'a [u8],
5) -> ::std::result::Result<Option<::std::vec::Vec<::std::string::String>>, ::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::StartArray { .. }) => {
12            let mut items = Vec::new();
13            loop {
14                match tokens.peek() {
15                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
16                        tokens.next().transpose().unwrap();
17                        break;
18                    }
19                    _ => {
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                            items.push(value);
25                        } else {
26                            return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
27                                "dense list cannot contain null values",
28                            ));
29                        }
30                    }
31                }
32            }
33            Ok(Some(items))
34        }
35        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
36            "expected start array or null",
37        )),
38    }
39}