aws_sdk_dynamodb/protocol_serde/
shape_stream_specification.rs1pub fn ser_stream_specification(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::StreamSpecification,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 {
7 object.key("StreamEnabled").boolean(input.stream_enabled);
8 }
9 if let Some(var_1) = &input.stream_view_type {
10 object.key("StreamViewType").string(var_1.as_str());
11 }
12 Ok(())
13}
14
15pub(crate) fn de_stream_specification<'a, I>(
16 tokens: &mut ::std::iter::Peekable<I>,
17) -> ::std::result::Result<Option<crate::types::StreamSpecification>, ::aws_smithy_json::deserialize::error::DeserializeError>
18where
19 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
20{
21 match tokens.next().transpose()? {
22 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
23 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
24 #[allow(unused_mut)]
25 let mut builder = crate::types::builders::StreamSpecificationBuilder::default();
26 loop {
27 match tokens.next().transpose()? {
28 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
29 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
30 "StreamEnabled" => {
31 builder = builder.set_stream_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
32 }
33 "StreamViewType" => {
34 builder = builder.set_stream_view_type(
35 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
36 .map(|s| s.to_unescaped().map(|u| crate::types::StreamViewType::from(u.as_ref())))
37 .transpose()?,
38 );
39 }
40 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
41 },
42 other => {
43 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
44 "expected object key or end object, found: {:?}",
45 other
46 )))
47 }
48 }
49 }
50 Ok(Some(crate::serde_util::stream_specification_correct_errors(builder).build().map_err(
51 |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
52 )?))
53 }
54 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
55 "expected start object or null",
56 )),
57 }
58}