aws_sdk_databrew/protocol_serde/
shape_dataset.rs1pub(crate) fn de_dataset<'a, I>(
3 tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::Dataset>, ::aws_smithy_json::deserialize::error::DeserializeError>
5where
6 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
7{
8 match tokens.next().transpose()? {
9 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
10 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
11 #[allow(unused_mut)]
12 let mut builder = crate::types::builders::DatasetBuilder::default();
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, .. }) => match key.to_unescaped()?.as_ref() {
17 "AccountId" => {
18 builder = builder.set_account_id(
19 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
20 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
21 .transpose()?,
22 );
23 }
24 "CreatedBy" => {
25 builder = builder.set_created_by(
26 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
27 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
28 .transpose()?,
29 );
30 }
31 "CreateDate" => {
32 builder = builder.set_create_date(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
33 tokens.next(),
34 ::aws_smithy_types::date_time::Format::EpochSeconds,
35 )?);
36 }
37 "Name" => {
38 builder = builder.set_name(
39 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
40 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
41 .transpose()?,
42 );
43 }
44 "Format" => {
45 builder = builder.set_format(
46 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
47 .map(|s| s.to_unescaped().map(|u| crate::types::InputFormat::from(u.as_ref())))
48 .transpose()?,
49 );
50 }
51 "FormatOptions" => {
52 builder = builder.set_format_options(crate::protocol_serde::shape_format_options::de_format_options(tokens)?);
53 }
54 "Input" => {
55 builder = builder.set_input(crate::protocol_serde::shape_input::de_input(tokens)?);
56 }
57 "LastModifiedDate" => {
58 builder = builder.set_last_modified_date(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
59 tokens.next(),
60 ::aws_smithy_types::date_time::Format::EpochSeconds,
61 )?);
62 }
63 "LastModifiedBy" => {
64 builder = builder.set_last_modified_by(
65 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
66 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
67 .transpose()?,
68 );
69 }
70 "Source" => {
71 builder = builder.set_source(
72 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
73 .map(|s| s.to_unescaped().map(|u| crate::types::Source::from(u.as_ref())))
74 .transpose()?,
75 );
76 }
77 "PathOptions" => {
78 builder = builder.set_path_options(crate::protocol_serde::shape_path_options::de_path_options(tokens)?);
79 }
80 "Tags" => {
81 builder = builder.set_tags(crate::protocol_serde::shape_tag_map::de_tag_map(tokens)?);
82 }
83 "ResourceArn" => {
84 builder = builder.set_resource_arn(
85 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
86 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
87 .transpose()?,
88 );
89 }
90 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
91 },
92 other => {
93 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
94 "expected object key or end object, found: {:?}",
95 other
96 )))
97 }
98 }
99 }
100 Ok(Some(crate::serde_util::dataset_correct_errors(builder).build().map_err(|err| {
101 ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err)
102 })?))
103 }
104 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
105 "expected start object or null",
106 )),
107 }
108}