1 - | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 - | pub(crate) fn de_innermost_shape<'a, I>(
|
3 - | tokens: &mut ::std::iter::Peekable<I>,
|
4 - | _value: &'a [u8],
|
5 - | ) -> ::std::result::Result<Option<crate::types::InnermostShape>, ::aws_smithy_json::deserialize::error::DeserializeError>
|
6 - | where
|
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 - | #[allow(unused_mut)]
|
13 - | let mut builder = crate::types::builders::InnermostShapeBuilder::default();
|
14 - | loop {
|
15 - | match tokens.next().transpose()? {
|
16 - | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
17 - | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
|
18 - | "aString" => {
|
19 - | builder = builder.set_a_string(
|
20 - | ::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 - | );
|
24 - | }
|
25 - | "aBoolean" => {
|
26 - | builder = builder.set_a_boolean(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
|
27 - | }
|
28 - | "aByte" => {
|
29 - | builder = builder.set_a_byte(
|
30 - | ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
|
31 - | .map(i8::try_from)
|
32 - | .transpose()?,
|
33 - | );
|
34 - | }
|
35 - | "aShort" => {
|
36 - | builder = builder.set_a_short(
|
37 - | ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
|
38 - | .map(i16::try_from)
|
39 - | .transpose()?,
|
40 - | );
|
41 - | }
|
42 - | "anInt" => {
|
43 - | builder = builder.set_an_int(
|
44 - | ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
|
45 - | .map(i32::try_from)
|
46 - | .transpose()?,
|
47 - | );
|
48 - | }
|
49 - | "aLong" => {
|
50 - | builder = builder.set_a_long(
|
51 - | ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
|
52 - | .map(i64::try_from)
|
53 - | .transpose()?,
|
54 - | );
|
55 - | }
|
56 - | "aFloat" => {
|
57 - | builder = builder
|
58 - | .set_a_float(::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?.map(|v| v.to_f32_lossy()));
|
59 - | }
|
60 - | "aDouble" => {
|
61 - | builder = builder
|
62 - | .set_a_double(::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?.map(|v| v.to_f64_lossy()));
|
63 - | }
|
64 - | "aBigInteger" => {
|
65 - | builder = builder.set_a_big_integer(
|
66 - | ::aws_smithy_json::deserialize::token::expect_number_as_string_or_null(tokens.next(), _value)?
|
67 - | .map(<::aws_smithy_types::BigInteger as ::std::str::FromStr>::from_str)
|
68 - | .transpose()
|
69 - | .map_err(|e| {
|
70 - | ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!("invalid BigInteger: {e}"))
|
71 - | })?,
|
72 - | );
|
73 - | }
|
74 - | "aBigDecimal" => {
|
75 - | builder = builder.set_a_big_decimal(
|
76 - | ::aws_smithy_json::deserialize::token::expect_number_as_string_or_null(tokens.next(), _value)?
|
77 - | .map(<::aws_smithy_types::BigDecimal as ::std::str::FromStr>::from_str)
|
78 - | .transpose()
|
79 - | .map_err(|e| {
|
80 - | ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!("invalid BigDecimal: {e}"))
|
81 - | })?,
|
82 - | );
|
83 - | }
|
84 - | "aTimestamp" => {
|
85 - | builder = builder.set_a_timestamp(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
|
86 - | tokens.next(),
|
87 - | ::aws_smithy_types::date_time::Format::EpochSeconds,
|
88 - | )?);
|
89 - | }
|
90 - | "aDocument" => {
|
91 - | builder = builder.set_a_document(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
|
92 - | tokens.next(),
|
93 - | ::aws_smithy_types::date_time::Format::EpochSeconds,
|
94 - | )?);
|
95 - | }
|
96 - | "aStringList" => {
|
97 - | builder = builder.set_a_string_list(crate::protocol_serde::shape_a_string_list::de_a_string_list(tokens, _value)?);
|
98 - | }
|
99 - | "aStringMap" => {
|
100 - | builder = builder.set_a_string_map(crate::protocol_serde::shape_a_map::de_a_map(tokens, _value)?);
|
101 - | }
|
102 - | "aStringSet" => {
|
103 - | builder = builder.set_a_string_set(crate::protocol_serde::shape_a_string_set::de_a_string_set(tokens, _value)?);
|
104 - | }
|
105 - | "aBlob" => {
|
106 - | builder = builder.set_a_blob(::aws_smithy_json::deserialize::token::expect_blob_or_null(tokens.next())?);
|
107 - | }
|
108 - | "aUnion" => {
|
109 - | builder = builder.set_a_union(crate::protocol_serde::shape_a_union::de_a_union(tokens, _value)?);
|
110 - | }
|
111 - | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
|
112 - | },
|
113 - | other => {
|
114 - | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
115 - | "expected object key or end object, found: {other:?}"
|
116 - | )))
|
117 - | }
|
118 - | }
|
119 - | }
|
120 - | Ok(Some(crate::serde_util::innermost_shape_correct_errors(builder).build().map_err(
|
121 - | |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
|
122 - | )?))
|
123 - | }
|
124 - | _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
125 - | "expected start object or null",
|
126 - | )),
|
127 - | }
|
128 - | }
|
129 - |
|
130 - | pub fn ser_innermost_shape(
|
131 - | object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
|
132 - | input: &crate::types::InnermostShape,
|
133 - | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
|
134 - | {
|
135 - | object.key("aString").string(input.a_string.as_str());
|
136 - | }
|
137 - | {
|
138 - | object.key("aBoolean").boolean(input.a_boolean);
|
139 - | }
|
140 - | {
|
141 - | object.key("aByte").number(
|
142 - | #[allow(clippy::useless_conversion)]
|
143 - | ::aws_smithy_types::Number::NegInt((input.a_byte).into()),
|
144 - | );
|
145 - | }
|
146 - | {
|
147 - | object.key("aShort").number(
|
148 - | #[allow(clippy::useless_conversion)]
|
149 - | ::aws_smithy_types::Number::NegInt((input.a_short).into()),
|
150 - | );
|
151 - | }
|
152 - | {
|
153 - | object.key("anInt").number(
|
154 - | #[allow(clippy::useless_conversion)]
|
155 - | ::aws_smithy_types::Number::NegInt((input.an_int).into()),
|
156 - | );
|
157 - | }
|
158 - | {
|
159 - | object.key("aLong").number(
|
160 - | #[allow(clippy::useless_conversion)]
|
161 - | ::aws_smithy_types::Number::NegInt((input.a_long).into()),
|
162 - | );
|
163 - | }
|
164 - | {
|
165 - | object.key("aFloat").number(
|
166 - | #[allow(clippy::useless_conversion)]
|
167 - | ::aws_smithy_types::Number::Float((input.a_float).into()),
|
168 - | );
|
169 - | }
|
170 - | {
|
171 - | object.key("aDouble").number(
|
172 - | #[allow(clippy::useless_conversion)]
|
173 - | ::aws_smithy_types::Number::Float((input.a_double).into()),
|
174 - | );
|
175 - | }
|
176 - | {
|
177 - | object.key("aBigInteger").write_raw_value(input.a_big_integer.as_ref());
|
178 - | }
|
179 - | {
|
180 - | object.key("aBigDecimal").write_raw_value(input.a_big_decimal.as_ref());
|
181 - | }
|
182 - | {
|
183 - | object
|
184 - | .key("aTimestamp")
|
185 - | .date_time(&input.a_timestamp, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
|
186 - | }
|
187 - | {
|
188 - | object
|
189 - | .key("aDocument")
|
190 - | .date_time(&input.a_document, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
|
191 - | }
|
192 - | {
|
193 - | let mut array_1 = object.key("aStringList").start_array();
|
194 - | for item_2 in &input.a_string_list {
|
195 - | {
|
196 - | array_1.value().string(item_2.as_str());
|
197 - | }
|
198 - | }
|
199 - | array_1.finish();
|
200 - | }
|
201 - | {
|
202 - | #[allow(unused_mut)]
|
203 - | let mut object_3 = object.key("aStringMap").start_object();
|
204 - | for (key_4, value_5) in &input.a_string_map {
|
205 - | {
|
206 - | object_3
|
207 - | .key(key_4.as_str())
|
208 - | .date_time(value_5, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
|
209 - | }
|
210 - | }
|
211 - | object_3.finish();
|
212 - | }
|
213 - | {
|
214 - | let mut array_6 = object.key("aStringSet").start_array();
|
215 - | for item_7 in &input.a_string_set {
|
216 - | {
|
217 - | array_6.value().string(item_7.as_str());
|
218 - | }
|
219 - | }
|
220 - | array_6.finish();
|
221 - | }
|
222 - | {
|
223 - | object.key("aBlob").string_unchecked(&::aws_smithy_types::base64::encode(&input.a_blob));
|
224 - | }
|
225 - | {
|
226 - | #[allow(unused_mut)]
|
227 - | let mut object_8 = object.key("aUnion").start_object();
|
228 - | crate::protocol_serde::shape_a_union::ser_a_union(&mut object_8, &input.a_union)?;
|
229 - | object_8.finish();
|
230 - | }
|
231 - | Ok(())
|
232 - | }
|